[WIP] Add custom domain support for auctions flow #50
@ -345,10 +345,11 @@ export const createResolvers = async (service: Service): Promise<any> => {
|
||||
{
|
||||
projectId,
|
||||
deploymentId,
|
||||
}: { deploymentId: string; projectId: string },
|
||||
deployerLrn,
|
||||
}: { deploymentId: string; projectId: string, deployerLrn: string },
|
||||
) => {
|
||||
try {
|
||||
return await service.rollbackDeployment(projectId, deploymentId);
|
||||
return await service.rollbackDeployment(projectId, deploymentId, deployerLrn);
|
||||
} catch (err) {
|
||||
log(err);
|
||||
return false;
|
||||
|
@ -111,6 +111,7 @@ type Deployment {
|
||||
isCurrent: Boolean!
|
||||
baseDomain: String
|
||||
status: DeploymentStatus!
|
||||
dnsRecordData: DNSRecordAttributes
|
||||
createdAt: String!
|
||||
updatedAt: String!
|
||||
createdBy: User!
|
||||
|
@ -644,15 +644,20 @@ export class Service {
|
||||
|
||||
const octokit = await this.getOctokit(user.id);
|
||||
|
||||
const newDeployment = await this.createDeployment(user.id, octokit, {
|
||||
project: oldDeployment.project,
|
||||
branch: oldDeployment.branch,
|
||||
environment: Environment.Production,
|
||||
commitHash: oldDeployment.commitHash,
|
||||
commitMessage: oldDeployment.commitMessage,
|
||||
deployer: oldDeployment.deployer
|
||||
});
|
||||
let newDeployment: Deployment;
|
||||
|
||||
if (oldDeployment.project.auctionId) {
|
||||
newDeployment = await this.createDeploymentFromAuction(oldDeployment.project, oldDeployment.deployer);
|
||||
} else {
|
||||
newDeployment = await this.createDeployment(user.id, octokit, {
|
||||
project: oldDeployment.project,
|
||||
branch: oldDeployment.branch,
|
||||
environment: Environment.Production,
|
||||
commitHash: oldDeployment.commitHash,
|
||||
commitMessage: oldDeployment.commitMessage,
|
||||
deployer: oldDeployment.deployer
|
||||
});
|
||||
}
|
||||
return newDeployment;
|
||||
}
|
||||
|
||||
@ -1188,6 +1193,7 @@ export class Service {
|
||||
async rollbackDeployment(
|
||||
projectId: string,
|
||||
deploymentId: string,
|
||||
deployerLrn: string,
|
||||
): Promise<boolean> {
|
||||
// TODO: Implement transactions
|
||||
const oldCurrentDeployment = await this.db.getDeployment({
|
||||
@ -1199,6 +1205,9 @@ export class Service {
|
||||
project: {
|
||||
id: projectId,
|
||||
},
|
||||
deployer: {
|
||||
deployerLrn
|
||||
},
|
||||
isCurrent: true,
|
||||
isCanonical: false,
|
||||
},
|
||||
|
@ -99,6 +99,7 @@ export const DeploymentMenu = ({
|
||||
const isRollbacked = await client.rollbackDeployment(
|
||||
project.id,
|
||||
deployment.id,
|
||||
deployment.deployer.deployerLrn
|
||||
);
|
||||
if (isRollbacked.rollbackDeployment) {
|
||||
await onUpdate();
|
||||
|
@ -8,13 +8,14 @@ import {
|
||||
MenuList,
|
||||
MenuItem,
|
||||
Card,
|
||||
Tooltip,
|
||||
} from '@snowballtools/material-tailwind-react-fork';
|
||||
|
||||
import EditDomainDialog from './EditDomainDialog';
|
||||
import { useGQLClient } from 'context/GQLClientContext';
|
||||
import { DeleteDomainDialog } from 'components/projects/Dialog/DeleteDomainDialog';
|
||||
import { useToast } from 'components/shared/Toast';
|
||||
import { GearIcon } from 'components/shared/CustomIcon';
|
||||
import { GearIcon, InfoRoundFilledIcon } from 'components/shared/CustomIcon';
|
||||
import { Heading } from 'components/shared/Heading';
|
||||
import { Button } from 'components/shared/Button';
|
||||
import { useParams } from 'react-router-dom';
|
||||
@ -44,7 +45,6 @@ interface DomainCardProps {
|
||||
onUpdate: () => Promise<void>;
|
||||
}
|
||||
|
||||
|
||||
const DomainCard = ({
|
||||
domains,
|
||||
domain,
|
||||
@ -56,7 +56,9 @@ const DomainCard = ({
|
||||
const { id } = useParams();
|
||||
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
||||
const [editDialogOpen, setEditDialogOpen] = useState(false);
|
||||
const [dnsRecord, setDnsRecord] = useState<DNSRecordAttributes | null>(null);
|
||||
const [dnsRecordsWithLRN, setDnsRecordsWithLRN] = useState<
|
||||
{ dnsRecord: DNSRecordAttributes; deployerLRN: string }[]
|
||||
>([]);
|
||||
// const [refreshStatus, SetRefreshStatus] = useState(RefreshStatus.IDLE);
|
||||
|
||||
const client = useGQLClient();
|
||||
@ -94,9 +96,26 @@ const DomainCard = ({
|
||||
return;
|
||||
}
|
||||
|
||||
const dnsRecordResponse = await client.getLatestDNSRecordByProjectId(id);
|
||||
const dnsRecordResponse = await client.getProject(id);
|
||||
|
||||
setDnsRecord(dnsRecordResponse.latestDNSRecord);
|
||||
if (!dnsRecordResponse.project) {
|
||||
return;
|
||||
}
|
||||
|
||||
const tempDNSRecords: {
|
||||
dnsRecord: DNSRecordAttributes;
|
||||
deployerLRN: string;
|
||||
}[] = [];
|
||||
for (const deployment of dnsRecordResponse.project.deployments) {
|
||||
if (deployment.dnsRecordData.value) {
|
||||
tempDNSRecords.push({
|
||||
dnsRecord: deployment.dnsRecordData,
|
||||
deployerLRN: deployment.deployer.deployerLrn,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setDnsRecordsWithLRN(tempDNSRecords);
|
||||
};
|
||||
|
||||
fetchDNSData();
|
||||
@ -182,11 +201,16 @@ const DomainCard = ({
|
||||
<Typography variant="small">Production</Typography>
|
||||
{domain.status === DomainStatus.Pending && (
|
||||
<Card className="bg-slate-100 p-4 text-sm">
|
||||
{/* {refreshStatus === RefreshStatus.IDLE ? ( */}
|
||||
<Heading>
|
||||
^ Add these records to your domain {/* and refresh to check */}
|
||||
</Heading>
|
||||
{/* ) : refreshStatus === RefreshStatus.CHECKING ? (
|
||||
{dnsRecordsWithLRN.length ? (
|
||||
<>
|
||||
{/* {refreshStatus === RefreshStatus.IDLE ? ( */}
|
||||
<Heading>
|
||||
<p className="text-blue-gray-500 pb-3">
|
||||
^ Add these records to your domain{' '}
|
||||
{/* and refresh to check */}
|
||||
</p>
|
||||
</Heading>
|
||||
{/* ) : refreshStatus === RefreshStatus.CHECKING ? (
|
||||
<Heading className="text-blue-500">
|
||||
^ Checking records for {domain.name}
|
||||
</Heading>
|
||||
@ -199,26 +223,49 @@ const DomainCard = ({
|
||||
</div>
|
||||
)} */}
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="text-left">Type</th>
|
||||
<th className="text-left">Name</th>
|
||||
<th className="text-left">Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{dnsRecord ? (
|
||||
<tr>
|
||||
<td>{dnsRecord.resourceType}</td>
|
||||
<td>@</td>
|
||||
<td>{dnsRecord.value ?? 'Not Configured'}</td>
|
||||
</tr>
|
||||
) : (
|
||||
<p className={'text-red-500'}>DNS record data not available</p>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th className="text-left">Type</th>
|
||||
<th className="text-left">Name</th>
|
||||
<th className="text-left">Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{dnsRecordsWithLRN.map((record) => {
|
||||
return (
|
||||
<>
|
||||
<tbody>
|
||||
<tr>
|
||||
<Tooltip
|
||||
content={
|
||||
<div>
|
||||
<p className="inline text-white">
|
||||
Service Provider:
|
||||
</p>
|
||||
<p className="text-blue-gray-300 pl-2 inline">
|
||||
{record.deployerLRN}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<td>
|
||||
<InfoRoundFilledIcon />
|
||||
</td>
|
||||
</Tooltip>
|
||||
<td>{record.dnsRecord.resourceType}</td>
|
||||
<td>@</td>
|
||||
<td>{record.dnsRecord.value}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</>
|
||||
);
|
||||
})}
|
||||
</table>
|
||||
</>
|
||||
) : (
|
||||
<p className="text-red-500">DNS record data not available</p>
|
||||
)}
|
||||
</Card>
|
||||
)}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import {
|
||||
AppDeploymentRecordAttributes,
|
||||
Deployment,
|
||||
DeploymentStatus,
|
||||
DNSRecordAttributes,
|
||||
Domain,
|
||||
DomainStatus,
|
||||
Environment,
|
||||
@ -50,6 +51,7 @@ const deployment: Deployment = {
|
||||
applicationDeploymentRequestId:
|
||||
'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize',
|
||||
applicationDeploymentRecordData: {} as AppDeploymentRecordAttributes,
|
||||
dnsRecordData: {} as DNSRecordAttributes,
|
||||
};
|
||||
|
||||
const domains: Domain[] = [
|
||||
|
@ -60,39 +60,31 @@ const Domains = () => {
|
||||
return (
|
||||
<ProjectSettingContainer
|
||||
headingText="Domains"
|
||||
{...(!project.auctionId && {
|
||||
button: (
|
||||
<Button
|
||||
as="a"
|
||||
href="add"
|
||||
variant="secondary"
|
||||
leftIcon={<PlusIcon />}
|
||||
size="md"
|
||||
>
|
||||
Add domain
|
||||
</Button>
|
||||
),
|
||||
})}
|
||||
button={
|
||||
<Button
|
||||
as="a"
|
||||
href="add"
|
||||
variant="secondary"
|
||||
leftIcon={<PlusIcon />}
|
||||
size="md"
|
||||
>
|
||||
Add domain
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
{project.auctionId ? (
|
||||
<p className="text-gray-500">
|
||||
Custom domains not supported for auction driven deployments.
|
||||
</p>
|
||||
) : (
|
||||
domains.map((domain) => {
|
||||
return (
|
||||
<DomainCard
|
||||
domains={domains}
|
||||
domain={domain}
|
||||
key={domain.id}
|
||||
// TODO: Use github API for getting linked repository
|
||||
branches={branches}
|
||||
project={project}
|
||||
onUpdate={fetchDomains}
|
||||
/>
|
||||
);
|
||||
})
|
||||
)}
|
||||
{domains.map((domain) => {
|
||||
return (
|
||||
<DomainCard
|
||||
domains={domains}
|
||||
domain={domain}
|
||||
key={domain.id}
|
||||
// TODO: Use github API for getting linked repository
|
||||
branches={branches}
|
||||
project={project}
|
||||
onUpdate={fetchDomains}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</ProjectSettingContainer>
|
||||
);
|
||||
};
|
||||
|
@ -18,7 +18,9 @@ const Config = () => {
|
||||
const primaryDomainName = searchParams.get('name');
|
||||
const { toast, dismiss } = useToast();
|
||||
|
||||
const [dnsRecord, setDnsRecord] = useState<DNSRecordAttributes | null>(null);
|
||||
const [dnsRecordsWithLRN, setDnsRecordsWithLRN] = useState<
|
||||
{ dnsRecord: DNSRecordAttributes; deployerLRN: string }[]
|
||||
>([]);
|
||||
|
||||
const handleSubmitDomain = async () => {
|
||||
if (primaryDomainName === null) {
|
||||
@ -75,9 +77,26 @@ const Config = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const dnsRecordResponse = await client.getLatestDNSRecordByProjectId(id);
|
||||
const dnsRecordResponse = await client.getProject(id);
|
||||
|
||||
setDnsRecord(dnsRecordResponse.latestDNSRecord);
|
||||
if (!dnsRecordResponse.project) {
|
||||
return;
|
||||
}
|
||||
|
||||
const tempDNSRecords: {
|
||||
dnsRecord: DNSRecordAttributes;
|
||||
deployerLRN: string;
|
||||
}[] = [];
|
||||
for (const deployment of dnsRecordResponse.project.deployments) {
|
||||
if (deployment.dnsRecordData.value) {
|
||||
tempDNSRecords.push({
|
||||
dnsRecord: deployment.dnsRecordData,
|
||||
deployerLRN: deployment.deployer.deployerLrn,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setDnsRecordsWithLRN(tempDNSRecords);
|
||||
};
|
||||
|
||||
fetchDNSData();
|
||||
@ -86,57 +105,66 @@ const Config = () => {
|
||||
// TODO: Figure out DNS Provider if possible and update appropriatly
|
||||
return (
|
||||
<ProjectSettingContainer headingText="Setup domain name">
|
||||
{dnsRecord ? (
|
||||
{dnsRecordsWithLRN.length ? (
|
||||
<>
|
||||
<p className="text-blue-gray-500">
|
||||
Add the following records to your domain.
|
||||
</p>
|
||||
|
||||
<Table>
|
||||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.ColumnHeaderCell>Type</Table.ColumnHeaderCell>
|
||||
<Table.ColumnHeaderCell>Host</Table.ColumnHeaderCell>
|
||||
<Table.ColumnHeaderCell>Value</Table.ColumnHeaderCell>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
|
||||
<Table.Body>
|
||||
<Table.Row>
|
||||
<Table.RowHeaderCell>
|
||||
{dnsRecord.resourceType}
|
||||
</Table.RowHeaderCell>
|
||||
<Table.Cell>@</Table.Cell>
|
||||
<Table.Cell>
|
||||
<p className={!dnsRecord.value ? 'text-red-500' : ''}>
|
||||
{dnsRecord.value ?? 'Not available'}
|
||||
</p>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
</Table.Body>
|
||||
</Table>
|
||||
|
||||
{dnsRecord?.value && (
|
||||
<InlineNotification
|
||||
variant="info"
|
||||
title={`It can take up to 48 hours for these updates to reflect
|
||||
globally.`}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
className="w-fit"
|
||||
disabled={!dnsRecord?.value}
|
||||
onClick={handleSubmitDomain}
|
||||
variant="primary"
|
||||
shape="default"
|
||||
rightIcon={<ArrowRightCircleIcon />}
|
||||
>
|
||||
FINISH
|
||||
</Button>
|
||||
{dnsRecordsWithLRN.map((record) => {
|
||||
if (record.dnsRecord.value) {
|
||||
return (
|
||||
<>
|
||||
<div className="pt-6">
|
||||
<p className="text-gray-100 inline">Service Provider:</p>
|
||||
<p className="text-blue-gray-500 pl-2 inline">
|
||||
{record.deployerLRN}
|
||||
</p>
|
||||
</div>
|
||||
<Table>
|
||||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.ColumnHeaderCell>Type</Table.ColumnHeaderCell>
|
||||
<Table.ColumnHeaderCell>Host</Table.ColumnHeaderCell>
|
||||
<Table.ColumnHeaderCell>Value</Table.ColumnHeaderCell>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
<Table.Row>
|
||||
<Table.RowHeaderCell>
|
||||
{record.dnsRecord.resourceType}
|
||||
</Table.RowHeaderCell>
|
||||
<Table.Cell>@</Table.Cell>
|
||||
<Table.Cell>
|
||||
<p>{record.dnsRecord.value}</p>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
</Table.Body>
|
||||
</Table>
|
||||
</>
|
||||
);
|
||||
}
|
||||
})}
|
||||
</>
|
||||
) : (
|
||||
<p className={'text-red-500'}>DNS record data not available</p>
|
||||
)}
|
||||
{dnsRecordsWithLRN.length && (
|
||||
<InlineNotification
|
||||
variant="info"
|
||||
title={`It can take up to 48 hours for these updates to reflect
|
||||
globally.`}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
className="w-fit"
|
||||
disabled={!dnsRecordsWithLRN.length}
|
||||
onClick={handleSubmitDomain}
|
||||
variant="primary"
|
||||
shape="default"
|
||||
rightIcon={<ArrowRightCircleIcon />}
|
||||
>
|
||||
FINISH
|
||||
</Button>
|
||||
</ProjectSettingContainer>
|
||||
);
|
||||
};
|
||||
|
@ -13,6 +13,7 @@ import {
|
||||
Environment,
|
||||
Permission,
|
||||
AppDeploymentRecordAttributes,
|
||||
DNSRecordAttributes,
|
||||
} from 'gql-client';
|
||||
|
||||
export const user: User = {
|
||||
@ -112,6 +113,7 @@ export const deployment0: Deployment = {
|
||||
applicationDeploymentRequestId:
|
||||
'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize',
|
||||
applicationDeploymentRecordData: {} as AppDeploymentRecordAttributes,
|
||||
dnsRecordData: {} as DNSRecordAttributes,
|
||||
};
|
||||
|
||||
export const project: Project = {
|
||||
|
@ -337,13 +337,15 @@ export class GQLClient {
|
||||
|
||||
async rollbackDeployment(
|
||||
projectId: string,
|
||||
deploymentId: string
|
||||
deploymentId: string,
|
||||
deployerLrn: string,
|
||||
): Promise<types.RollbackDeploymentResponse> {
|
||||
const { data } = await this.client.mutate({
|
||||
mutation: mutations.rollbackDeployment,
|
||||
variables: {
|
||||
projectId,
|
||||
deploymentId,
|
||||
deployerLrn,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -95,8 +95,8 @@ export const deleteDomain = gql`
|
||||
`;
|
||||
|
||||
export const rollbackDeployment = gql`
|
||||
mutation ($projectId: String!, $deploymentId: String!) {
|
||||
rollbackDeployment(projectId: $projectId, deploymentId: $deploymentId)
|
||||
mutation ($projectId: String!, $deployerLrn: String!) {
|
||||
rollbackDeployment(projectId: $projectId, deployerLrn: $deployerLrn)
|
||||
}
|
||||
`;
|
||||
|
||||
|
@ -62,11 +62,19 @@ query ($projectId: String!) {
|
||||
}
|
||||
deployer {
|
||||
baseDomain
|
||||
deployerLrn
|
||||
}
|
||||
createdBy {
|
||||
id
|
||||
name
|
||||
}
|
||||
dnsRecordData {
|
||||
name
|
||||
value
|
||||
request
|
||||
resourceType
|
||||
version
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,6 +112,7 @@ export type Deployment = {
|
||||
createdBy: User;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
dnsRecordData: DNSRecordAttributes;
|
||||
applicationDeploymentRequestId: string;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user