diff --git a/packages/backend/src/resolvers.ts b/packages/backend/src/resolvers.ts index d9f9128d..c07723cc 100644 --- a/packages/backend/src/resolvers.ts +++ b/packages/backend/src/resolvers.ts @@ -345,10 +345,11 @@ export const createResolvers = async (service: Service): Promise => { { 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; diff --git a/packages/backend/src/schema.gql b/packages/backend/src/schema.gql index 400e36ef..1404adef 100644 --- a/packages/backend/src/schema.gql +++ b/packages/backend/src/schema.gql @@ -111,6 +111,7 @@ type Deployment { isCurrent: Boolean! baseDomain: String status: DeploymentStatus! + dnsRecordData: DNSRecordAttributes createdAt: String! updatedAt: String! createdBy: User! diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index 0321df01..7667164a 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -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 { // 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, }, diff --git a/packages/frontend/src/components/projects/project/deployments/DeploymentMenu.tsx b/packages/frontend/src/components/projects/project/deployments/DeploymentMenu.tsx index cb87aa98..5f2428b5 100644 --- a/packages/frontend/src/components/projects/project/deployments/DeploymentMenu.tsx +++ b/packages/frontend/src/components/projects/project/deployments/DeploymentMenu.tsx @@ -99,6 +99,7 @@ export const DeploymentMenu = ({ const isRollbacked = await client.rollbackDeployment( project.id, deployment.id, + deployment.deployer.deployerLrn ); if (isRollbacked.rollbackDeployment) { await onUpdate(); diff --git a/packages/frontend/src/components/projects/project/settings/DomainCard.tsx b/packages/frontend/src/components/projects/project/settings/DomainCard.tsx index 2fe0b05d..8b32eeca 100644 --- a/packages/frontend/src/components/projects/project/settings/DomainCard.tsx +++ b/packages/frontend/src/components/projects/project/settings/DomainCard.tsx @@ -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; } - 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(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 = ({ Production {domain.status === DomainStatus.Pending && ( - {/* {refreshStatus === RefreshStatus.IDLE ? ( */} - - ^ Add these records to your domain {/* and refresh to check */} - - {/* ) : refreshStatus === RefreshStatus.CHECKING ? ( + {dnsRecordsWithLRN.length ? ( + <> + {/* {refreshStatus === RefreshStatus.IDLE ? ( */} + +

+ ^ Add these records to your domain{' '} + {/* and refresh to check */} +

+
+ {/* ) : refreshStatus === RefreshStatus.CHECKING ? ( ^ Checking records for {domain.name} @@ -199,26 +223,49 @@ const DomainCard = ({ )} */} - - - - - - - - - - {dnsRecord ? ( - - - - - - ) : ( -

DNS record data not available

- )} - -
TypeNameValue
{dnsRecord.resourceType}@{dnsRecord.value ?? 'Not Configured'}
+ + + + + + + + + + {dnsRecordsWithLRN.map((record) => { + return ( + <> + + + +

+ Service Provider: +

+

+ {record.deployerLRN} +

+ + } + > +
+ + + + + + + + ); + })} +
TypeNameValue
+ + {record.dnsRecord.resourceType}@{record.dnsRecord.value}
+ + ) : ( +

DNS record data not available

+ )}
)} diff --git a/packages/frontend/src/pages/components/modals.tsx b/packages/frontend/src/pages/components/modals.tsx index 2b291a9f..39e18dc4 100644 --- a/packages/frontend/src/pages/components/modals.tsx +++ b/packages/frontend/src/pages/components/modals.tsx @@ -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[] = [ diff --git a/packages/frontend/src/pages/org-slug/projects/id/settings/Domains.tsx b/packages/frontend/src/pages/org-slug/projects/id/settings/Domains.tsx index 01e98c6c..0de97ac0 100644 --- a/packages/frontend/src/pages/org-slug/projects/id/settings/Domains.tsx +++ b/packages/frontend/src/pages/org-slug/projects/id/settings/Domains.tsx @@ -60,39 +60,31 @@ const Domains = () => { return ( } - size="md" - > - Add domain - - ), - })} + button={ + + } > - {project.auctionId ? ( -

- Custom domains not supported for auction driven deployments. -

- ) : ( - domains.map((domain) => { - return ( - - ); - }) - )} + {domains.map((domain) => { + return ( + + ); + })}
); }; diff --git a/packages/frontend/src/pages/org-slug/projects/id/settings/domains/add/Config.tsx b/packages/frontend/src/pages/org-slug/projects/id/settings/domains/add/Config.tsx index b56fae5b..75895268 100644 --- a/packages/frontend/src/pages/org-slug/projects/id/settings/domains/add/Config.tsx +++ b/packages/frontend/src/pages/org-slug/projects/id/settings/domains/add/Config.tsx @@ -18,7 +18,9 @@ const Config = () => { const primaryDomainName = searchParams.get('name'); const { toast, dismiss } = useToast(); - const [dnsRecord, setDnsRecord] = useState(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 ( - {dnsRecord ? ( + {dnsRecordsWithLRN.length ? ( <>

Add the following records to your domain.

- - - - - Type - Host - Value - - - - - - - {dnsRecord.resourceType} - - @ - -

- {dnsRecord.value ?? 'Not available'} -

-
-
-
-
- - {dnsRecord?.value && ( - - )} - + {dnsRecordsWithLRN.map((record) => { + if (record.dnsRecord.value) { + return ( + <> +
+

Service Provider:

+

+ {record.deployerLRN} +

+
+ + + + Type + Host + Value + + + + + + {record.dnsRecord.resourceType} + + @ + +

{record.dnsRecord.value}

+
+
+
+
+ + ); + } + })} ) : (

DNS record data not available

)} + {dnsRecordsWithLRN.length && ( + + )} +
); }; diff --git a/packages/frontend/src/stories/MockStoriesData.ts b/packages/frontend/src/stories/MockStoriesData.ts index 97f63a14..5cee191e 100644 --- a/packages/frontend/src/stories/MockStoriesData.ts +++ b/packages/frontend/src/stories/MockStoriesData.ts @@ -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 = { diff --git a/packages/gql-client/src/client.ts b/packages/gql-client/src/client.ts index 49ddbb60..7ba014cf 100644 --- a/packages/gql-client/src/client.ts +++ b/packages/gql-client/src/client.ts @@ -337,13 +337,15 @@ export class GQLClient { async rollbackDeployment( projectId: string, - deploymentId: string + deploymentId: string, + deployerLrn: string, ): Promise { const { data } = await this.client.mutate({ mutation: mutations.rollbackDeployment, variables: { projectId, deploymentId, + deployerLrn, }, }); diff --git a/packages/gql-client/src/mutations.ts b/packages/gql-client/src/mutations.ts index 876e5611..d87c0f00 100644 --- a/packages/gql-client/src/mutations.ts +++ b/packages/gql-client/src/mutations.ts @@ -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) } `; diff --git a/packages/gql-client/src/queries.ts b/packages/gql-client/src/queries.ts index 2af5a1e3..0459b3c4 100644 --- a/packages/gql-client/src/queries.ts +++ b/packages/gql-client/src/queries.ts @@ -62,11 +62,19 @@ query ($projectId: String!) { } deployer { baseDomain + deployerLrn } createdBy { id name } + dnsRecordData { + name + value + request + resourceType + version + } } } } diff --git a/packages/gql-client/src/types.ts b/packages/gql-client/src/types.ts index 2370b414..12aa63a1 100644 --- a/packages/gql-client/src/types.ts +++ b/packages/gql-client/src/types.ts @@ -112,6 +112,7 @@ export type Deployment = { createdBy: User; createdAt: string; updatedAt: string; + dnsRecordData: DNSRecordAttributes; applicationDeploymentRequestId: string; };