Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d93afb564b | ||
|
|
285d0e86bf | ||
|
|
13cc0f8b9b | ||
|
|
93b74074a3 | ||
|
|
b0d3c0593a | ||
|
|
a51765dae5 |
No files matched your search
@@ -158,10 +158,9 @@ export class Database {
|
||||
.leftJoinAndSelect(
|
||||
'project.deployments',
|
||||
'deployments',
|
||||
'deployments.isCurrent = true AND deployments.isDNS = true'
|
||||
'deployments.isCurrent = true AND deployments.isCanonical = true'
|
||||
)
|
||||
.leftJoinAndSelect('deployments.createdBy', 'user')
|
||||
.leftJoinAndSelect('deployments.domain', 'domain')
|
||||
.leftJoinAndSelect('deployments.deployer', 'deployer')
|
||||
.leftJoinAndSelect('project.owner', 'owner')
|
||||
.leftJoinAndSelect('project.deployers', 'deployers')
|
||||
@@ -203,9 +202,8 @@ export class Database {
|
||||
.leftJoinAndSelect(
|
||||
'project.deployments',
|
||||
'deployments',
|
||||
'deployments.isCurrent = true AND deployments.isDNS = true'
|
||||
'deployments.isCurrent = true AND deployments.isCanonical = true'
|
||||
)
|
||||
.leftJoinAndSelect('deployments.domain', 'domain')
|
||||
.leftJoin('project.projectMembers', 'projectMembers')
|
||||
.leftJoin('project.organization', 'organization')
|
||||
.where(
|
||||
@@ -236,7 +234,6 @@ export class Database {
|
||||
return this.getDeployments({
|
||||
relations: {
|
||||
project: true,
|
||||
domain: true,
|
||||
createdBy: true,
|
||||
deployer: true,
|
||||
},
|
||||
@@ -251,11 +248,10 @@ export class Database {
|
||||
});
|
||||
}
|
||||
|
||||
async getCommitDeploymentsByProjectId(projectId: string): Promise<Deployment[]> {
|
||||
async getNonCanonicalDeploymentsByProjectId(projectId: string): Promise<Deployment[]> {
|
||||
return this.getDeployments({
|
||||
relations: {
|
||||
project: true,
|
||||
domain: true,
|
||||
createdBy: true,
|
||||
deployer: true,
|
||||
},
|
||||
@@ -263,7 +259,7 @@ export class Database {
|
||||
project: {
|
||||
id: projectId
|
||||
},
|
||||
isDNS: false
|
||||
isCanonical: false
|
||||
},
|
||||
order: {
|
||||
createdAt: 'DESC'
|
||||
|
||||
@@ -39,6 +39,7 @@ export interface ApplicationDeploymentRequest {
|
||||
config: string;
|
||||
meta: string;
|
||||
payment?: string;
|
||||
dns?: string;
|
||||
}
|
||||
|
||||
export interface ApplicationDeploymentRemovalRequest {
|
||||
@@ -77,13 +78,6 @@ export class Deployment {
|
||||
@JoinColumn({ name: 'projectId' })
|
||||
project!: Project;
|
||||
|
||||
@Column({ nullable: true })
|
||||
domainId!: string | null;
|
||||
|
||||
@OneToOne(() => Domain)
|
||||
@JoinColumn({ name: 'domainId' })
|
||||
domain!: Domain | null;
|
||||
|
||||
@Column('varchar')
|
||||
branch!: string;
|
||||
|
||||
@@ -141,9 +135,8 @@ export class Deployment {
|
||||
@Column('boolean', { default: false })
|
||||
isCurrent!: boolean;
|
||||
|
||||
// TODO: Rename field
|
||||
@Column('boolean', { default: false })
|
||||
isDNS!: boolean;
|
||||
isCanonical!: boolean;
|
||||
|
||||
@Column({
|
||||
enum: DeploymentStatus
|
||||
|
||||
@@ -414,12 +414,8 @@ export class Registry {
|
||||
* Fetch record by Id
|
||||
*/
|
||||
async getRecordById(id: string): Promise<RegistryRecord | null> {
|
||||
const record = await this.registry.getRecordsByIds([id]);
|
||||
if (record.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return record[0];
|
||||
const [record] = await this.registry.getRecordsByIds([id]);
|
||||
return record ?? null;
|
||||
}
|
||||
|
||||
async createApplicationDeploymentRemovalRequest(data: {
|
||||
|
||||
@@ -38,7 +38,7 @@ export const createResolvers = async (service: Service): Promise<any> => {
|
||||
},
|
||||
|
||||
deployments: async (_: any, { projectId }: { projectId: string }) => {
|
||||
return service.getCommitDeploymentsByProjectId(projectId);
|
||||
return service.getNonCanonicalDeploymentsByProjectId(projectId);
|
||||
},
|
||||
|
||||
environmentVariables: async (
|
||||
@@ -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;
|
||||
|
||||
@@ -100,7 +100,6 @@ type ProjectMember {
|
||||
|
||||
type Deployment {
|
||||
id: String!
|
||||
domain: Domain
|
||||
branch: String!
|
||||
commitHash: String!
|
||||
commitMessage: String!
|
||||
@@ -112,6 +111,7 @@ type Deployment {
|
||||
isCurrent: Boolean!
|
||||
baseDomain: String
|
||||
status: DeploymentStatus!
|
||||
dnsRecordData: DNSRecordAttributes
|
||||
createdAt: String!
|
||||
updatedAt: String!
|
||||
createdBy: User!
|
||||
|
||||
+118
-105
@@ -228,12 +228,12 @@ export class Service {
|
||||
deployment.isCurrent = deployment.environment === Environment.Production;
|
||||
deployment.dnsRecordData = dnsRecordData;
|
||||
|
||||
if (deployment.isDNS) {
|
||||
const oldDNSDeployment = await this.db.getDeployment({
|
||||
if (deployment.isCanonical) {
|
||||
const previousCanonicalDeployment = await this.db.getDeployment({
|
||||
where: {
|
||||
projectId: deployment.project.id,
|
||||
deployer: deployment.deployer,
|
||||
isDNS: true,
|
||||
isCanonical: true,
|
||||
isCurrent: true,
|
||||
},
|
||||
relations: {
|
||||
@@ -242,26 +242,18 @@ export class Service {
|
||||
}
|
||||
});
|
||||
|
||||
if (oldDNSDeployment) {
|
||||
// Send removal request for the previous DNS deployment and delete DB entry
|
||||
if (oldDNSDeployment.url !== deployment.url) {
|
||||
if (previousCanonicalDeployment) {
|
||||
// Send removal request for the previous canonical deployment and delete DB entry
|
||||
if (previousCanonicalDeployment.url !== deployment.url) {
|
||||
await this.laconicRegistry.createApplicationDeploymentRemovalRequest({
|
||||
deploymentId: oldDNSDeployment.applicationDeploymentRecordId!,
|
||||
deployerLrn: oldDNSDeployment.deployer.deployerLrn,
|
||||
auctionId: oldDNSDeployment.project.auctionId,
|
||||
payment: oldDNSDeployment.project.txHash
|
||||
deploymentId: previousCanonicalDeployment.applicationDeploymentRecordId!,
|
||||
deployerLrn: previousCanonicalDeployment.deployer.deployerLrn,
|
||||
auctionId: previousCanonicalDeployment.project.auctionId,
|
||||
payment: previousCanonicalDeployment.project.txHash
|
||||
});
|
||||
}
|
||||
|
||||
await this.db.deleteDeploymentById(oldDNSDeployment.id);
|
||||
}
|
||||
|
||||
// Update domain after the previous DNS deployment is deleted due to unique key constraint for domain
|
||||
// Set the domain for the new current DNS deployment to the custom domain that was added for that project
|
||||
const customDomain = await this.db.getOldestDomainByProjectId(deployment.project.id);
|
||||
|
||||
if (customDomain) {
|
||||
deployment.domain = customDomain;
|
||||
await this.db.deleteDeploymentById(previousCanonicalDeployment.id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +293,7 @@ export class Service {
|
||||
projectDeployment.deployer.deployerLrn ===
|
||||
deployment.deployer.deployerLrn &&
|
||||
projectDeployment.id !== deployment.id &&
|
||||
projectDeployment.isDNS == deployment.isDNS,
|
||||
projectDeployment.isCanonical == deployment.isCanonical,
|
||||
);
|
||||
for (const oldDeployment of oldDeployments) {
|
||||
await this.db.updateDeployment(
|
||||
@@ -493,14 +485,14 @@ export class Service {
|
||||
return dbProjects;
|
||||
}
|
||||
|
||||
async getCommitDeploymentsByProjectId(projectId: string): Promise<Deployment[]> {
|
||||
const commitDeployments = await this.db.getCommitDeploymentsByProjectId(projectId);
|
||||
return commitDeployments;
|
||||
async getNonCanonicalDeploymentsByProjectId(projectId: string): Promise<Deployment[]> {
|
||||
const nonCanonicalDeployments = await this.db.getNonCanonicalDeploymentsByProjectId(projectId);
|
||||
return nonCanonicalDeployments;
|
||||
}
|
||||
|
||||
async getLatestDNSRecordByProjectId(projectId: string): Promise<DNSRecordAttributes | null> {
|
||||
const dnsDeployments = await this.db.getLatestDNSRecordByProjectId(projectId);
|
||||
return dnsDeployments;
|
||||
const dnsRecord = await this.db.getLatestDNSRecordByProjectId(projectId);
|
||||
return dnsRecord;
|
||||
}
|
||||
|
||||
async getEnvironmentVariablesByProjectId(
|
||||
@@ -642,6 +634,7 @@ export class Service {
|
||||
where: { id: deploymentId },
|
||||
relations: {
|
||||
project: true,
|
||||
deployer: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -649,23 +642,22 @@ export class Service {
|
||||
throw new Error('Deployment does not exist');
|
||||
}
|
||||
|
||||
const prodBranchDomains = await this.db.getDomainsByProjectId(
|
||||
oldDeployment.project.id,
|
||||
{ branch: oldDeployment.project.prodBranch },
|
||||
);
|
||||
|
||||
const octokit = await this.getOctokit(user.id);
|
||||
|
||||
const newDeployment = await this.createDeployment(user.id, octokit, {
|
||||
project: oldDeployment.project,
|
||||
branch: oldDeployment.branch,
|
||||
environment: Environment.Production,
|
||||
domain: prodBranchDomains[0],
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -689,19 +681,6 @@ export class Service {
|
||||
commitHash: data.commitHash!,
|
||||
});
|
||||
|
||||
// Update previous deployment with prod branch domain
|
||||
// TODO: Fix unique constraint error for domain
|
||||
if (data.domain) {
|
||||
await this.db.updateDeployment(
|
||||
{
|
||||
domainId: data.domain.id,
|
||||
},
|
||||
{
|
||||
domain: null,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
let deployer;
|
||||
if (deployerLrn) {
|
||||
deployer = await this.db.getDeployerByLRN(deployerLrn);
|
||||
@@ -710,26 +689,26 @@ export class Service {
|
||||
}
|
||||
|
||||
const deployment = await this.createDeploymentFromData(userId, data, deployer!.deployerLrn!, applicationRecordId, applicationRecordData, false);
|
||||
const dnsDeployment = await this.createDeploymentFromData(userId, data, deployer!.deployerLrn!, applicationRecordId, applicationRecordData, true);
|
||||
|
||||
const address = await this.getAddress();
|
||||
const { repo, repoUrl } = await getRepoDetails(octokit, data.project.repository, data.commitHash);
|
||||
const environmentVariablesObj = await this.getEnvVariables(data.project!.id!);
|
||||
|
||||
// If a custom domain is present then use that as the DNS in the deployment request
|
||||
const customDomain = await this.db.getOldestDomainByProjectId(data.project!.id!);
|
||||
|
||||
// To set project DNS
|
||||
if (data.environment === Environment.Production) {
|
||||
// On deleting deployment later, project DNS deployment is also deleted
|
||||
// So publish project DNS deployment first so that ApplicationDeploymentRecord for the same is available when deleting deployment later
|
||||
const canonicalDeployment = await this.createDeploymentFromData(userId, data, deployer!.deployerLrn!, applicationRecordId, applicationRecordData, true);
|
||||
// If a custom domain is present then use that as the DNS in the deployment request
|
||||
const customDomain = await this.db.getOldestDomainByProjectId(data.project!.id!);
|
||||
|
||||
// On deleting deployment later, project canonical deployment is also deleted
|
||||
// So publish project canonical deployment first so that ApplicationDeploymentRecord for the same is available when deleting deployment later
|
||||
const { applicationDeploymentRequestData, applicationDeploymentRequestId } =
|
||||
await this.laconicRegistry.createApplicationDeploymentRequest({
|
||||
deployment: dnsDeployment,
|
||||
deployment: canonicalDeployment,
|
||||
appName: repo,
|
||||
repository: repoUrl,
|
||||
environmentVariables: environmentVariablesObj,
|
||||
dns: customDomain?.name ?? `${dnsDeployment.project.name}`,
|
||||
dns: customDomain?.name ?? `${canonicalDeployment.project.name}`,
|
||||
lrn: deployer!.deployerLrn!,
|
||||
apiUrl: deployer!.deployerApiUrl!,
|
||||
payment: data.project.txHash,
|
||||
@@ -738,7 +717,7 @@ export class Service {
|
||||
publicKey: deployer!.publicKey!
|
||||
});
|
||||
|
||||
await this.db.updateDeploymentById(dnsDeployment.id, {
|
||||
await this.db.updateDeploymentById(canonicalDeployment.id, {
|
||||
applicationDeploymentRequestId,
|
||||
applicationDeploymentRequestData,
|
||||
});
|
||||
@@ -808,21 +787,24 @@ export class Service {
|
||||
};
|
||||
|
||||
const deployment = await this.createDeploymentFromData(project.ownerId!, deploymentData, deployerLrn, applicationRecordId, applicationRecordData, false);
|
||||
const dnsDeployment = await this.createDeploymentFromData(project.ownerId!, deploymentData, deployerLrn, applicationRecordId, applicationRecordData, true);
|
||||
const address = await this.getAddress();
|
||||
|
||||
const environmentVariablesObj = await this.getEnvVariables(project!.id!);
|
||||
// To set project DNS
|
||||
if (deploymentData.environment === Environment.Production) {
|
||||
// On deleting deployment later, project DNS deployment is also deleted
|
||||
// So publish project DNS deployment first so that ApplicationDeploymentRecord for the same is available when deleting deployment later
|
||||
const canonicalDeployment = await this.createDeploymentFromData(project.ownerId!, deploymentData, deployerLrn, applicationRecordId, applicationRecordData, true);
|
||||
// If a custom domain is present then use that as the DNS in the deployment request
|
||||
const customDomain = await this.db.getOldestDomainByProjectId(project!.id!);
|
||||
|
||||
// On deleting deployment later, project canonical deployment is also deleted
|
||||
// So publish project canonical deployment first so that ApplicationDeploymentRecord for the same is available when deleting deployment later
|
||||
const { applicationDeploymentRequestId, applicationDeploymentRequestData } =
|
||||
await this.laconicRegistry.createApplicationDeploymentRequest({
|
||||
deployment: dnsDeployment,
|
||||
deployment: canonicalDeployment,
|
||||
appName: repo,
|
||||
repository: repoUrl,
|
||||
environmentVariables: environmentVariablesObj,
|
||||
dns: `${dnsDeployment.project.name}`,
|
||||
dns: customDomain?.name ?? `${canonicalDeployment.project.name}`,
|
||||
auctionId: project.auctionId!,
|
||||
lrn: deployerLrn,
|
||||
apiUrl: deployer!.deployerApiUrl!,
|
||||
@@ -830,7 +812,7 @@ export class Service {
|
||||
publicKey: deployer!.publicKey!
|
||||
});
|
||||
|
||||
await this.db.updateDeploymentById(dnsDeployment.id, {
|
||||
await this.db.updateDeploymentById(canonicalDeployment.id, {
|
||||
applicationDeploymentRequestId,
|
||||
applicationDeploymentRequestData,
|
||||
});
|
||||
@@ -865,7 +847,7 @@ export class Service {
|
||||
deployerLrn: string,
|
||||
applicationRecordId: string,
|
||||
applicationRecordData: ApplicationRecord,
|
||||
isDNS: boolean,
|
||||
isCanonical: boolean,
|
||||
): Promise<Deployment> {
|
||||
const newDeployment = await this.db.addDeployment({
|
||||
project: data.project,
|
||||
@@ -876,14 +858,13 @@ export class Service {
|
||||
status: DeploymentStatus.Building,
|
||||
applicationRecordId,
|
||||
applicationRecordData,
|
||||
domain: data.domain,
|
||||
createdBy: Object.assign(new User(), {
|
||||
id: userId,
|
||||
}),
|
||||
deployer: Object.assign(new Deployer(), {
|
||||
deployerLrn,
|
||||
}),
|
||||
isDNS
|
||||
isCanonical
|
||||
});
|
||||
|
||||
log(`Created deployment ${newDeployment.id}`);
|
||||
@@ -1116,9 +1097,6 @@ export class Service {
|
||||
|
||||
for await (const project of projects) {
|
||||
const octokit = await this.getOctokit(project.ownerId);
|
||||
const [domain] = await this.db.getDomainsByProjectId(project.id, {
|
||||
branch,
|
||||
});
|
||||
|
||||
const deployers = project.deployers;
|
||||
if (!deployers) {
|
||||
@@ -1136,7 +1114,6 @@ export class Service {
|
||||
project.prodBranch === branch
|
||||
? Environment.Production
|
||||
: Environment.Preview,
|
||||
domain,
|
||||
commitHash: headCommit.id,
|
||||
commitMessage: headCommit.message,
|
||||
deployer: deployer
|
||||
@@ -1178,7 +1155,6 @@ export class Service {
|
||||
const oldDeployment = await this.db.getDeployment({
|
||||
relations: {
|
||||
project: true,
|
||||
domain: true,
|
||||
deployer: true,
|
||||
createdBy: true,
|
||||
},
|
||||
@@ -1204,7 +1180,6 @@ export class Service {
|
||||
// TODO: Put isCurrent field in project
|
||||
branch: oldDeployment.branch,
|
||||
environment: Environment.Production,
|
||||
domain: oldDeployment.domain,
|
||||
commitHash: oldDeployment.commitHash,
|
||||
commitMessage: oldDeployment.commitMessage,
|
||||
deployer: oldDeployment.deployer
|
||||
@@ -1218,11 +1193,11 @@ export class Service {
|
||||
async rollbackDeployment(
|
||||
projectId: string,
|
||||
deploymentId: string,
|
||||
deployerLrn: string,
|
||||
): Promise<boolean> {
|
||||
// TODO: Implement transactions
|
||||
const oldCurrentDeployment = await this.db.getDeployment({
|
||||
relations: {
|
||||
domain: true,
|
||||
project: true,
|
||||
deployer: true,
|
||||
},
|
||||
@@ -1230,8 +1205,11 @@ export class Service {
|
||||
project: {
|
||||
id: projectId,
|
||||
},
|
||||
deployer: {
|
||||
deployerLrn
|
||||
},
|
||||
isCurrent: true,
|
||||
isDNS: false,
|
||||
isCanonical: false,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1241,22 +1219,34 @@ export class Service {
|
||||
|
||||
const oldCurrentDeploymentUpdate = await this.db.updateDeploymentById(
|
||||
oldCurrentDeployment.id,
|
||||
{ isCurrent: false, domain: null },
|
||||
{ isCurrent: false },
|
||||
);
|
||||
|
||||
const newCurrentDeploymentUpdate = await this.db.updateDeploymentById(
|
||||
deploymentId,
|
||||
{ isCurrent: true, domain: oldCurrentDeployment.domain },
|
||||
{ isCurrent: true },
|
||||
);
|
||||
|
||||
if (!newCurrentDeploymentUpdate || !oldCurrentDeploymentUpdate){
|
||||
return false;
|
||||
}
|
||||
|
||||
const newCurrentDeployment = await this.db.getDeployment({ where: { id: deploymentId }, relations: { project: true, deployer: true } });
|
||||
|
||||
if (!newCurrentDeployment) {
|
||||
throw new Error(`Deployment with Id ${deploymentId} not found`);
|
||||
}
|
||||
|
||||
// Create a DNS deployment for the new current deployment
|
||||
const dnsDeployment = await this.createDeploymentFromData(
|
||||
const applicationDeploymentRequestData = newCurrentDeployment.applicationDeploymentRequestData;
|
||||
|
||||
const customDomain = await this.db.getOldestDomainByProjectId(projectId);
|
||||
|
||||
if (customDomain && applicationDeploymentRequestData) {
|
||||
applicationDeploymentRequestData.dns = customDomain.name
|
||||
}
|
||||
|
||||
// Create a canonical deployment for the new current deployment
|
||||
const canonicalDeployment = await this.createDeploymentFromData(
|
||||
newCurrentDeployment.project.ownerId,
|
||||
newCurrentDeployment,
|
||||
newCurrentDeployment.deployer!.deployerLrn!,
|
||||
@@ -1265,9 +1255,6 @@ export class Service {
|
||||
true,
|
||||
);
|
||||
|
||||
const applicationDeploymentRequestData = newCurrentDeployment.applicationDeploymentRequestData;
|
||||
|
||||
applicationDeploymentRequestData!.version = (Number(applicationDeploymentRequestData?.version) + 1).toString();
|
||||
applicationDeploymentRequestData!.meta = JSON.stringify({
|
||||
...JSON.parse(applicationDeploymentRequestData!.meta),
|
||||
note: `Updated by Snowball @ ${DateTime.utc().toFormat(
|
||||
@@ -1281,12 +1268,12 @@ export class Service {
|
||||
|
||||
log(`Application deployment request record published: ${result.id}`)
|
||||
|
||||
await this.db.updateDeploymentById(dnsDeployment.id, {
|
||||
const updateResult = await this.db.updateDeploymentById(canonicalDeployment.id, {
|
||||
applicationDeploymentRequestId: result.id,
|
||||
applicationDeploymentRequestData,
|
||||
});
|
||||
|
||||
return newCurrentDeploymentUpdate && oldCurrentDeploymentUpdate;
|
||||
return updateResult;
|
||||
}
|
||||
|
||||
async deleteDeployment(deploymentId: string): Promise<boolean> {
|
||||
@@ -1303,11 +1290,11 @@ export class Service {
|
||||
if (deployment && deployment.applicationDeploymentRecordId) {
|
||||
// If deployment is current, remove deployment for project subdomain as well
|
||||
if (deployment.isCurrent) {
|
||||
const dnsDeployment = await this.db.getDeployment({
|
||||
const canonicalDeployment = await this.db.getDeployment({
|
||||
where: {
|
||||
projectId: deployment.project.id,
|
||||
deployer: deployment.deployer,
|
||||
isDNS: true
|
||||
isCanonical: true
|
||||
},
|
||||
relations: {
|
||||
project: true,
|
||||
@@ -1315,27 +1302,53 @@ export class Service {
|
||||
},
|
||||
})
|
||||
|
||||
if (!dnsDeployment) {
|
||||
log(`DNS deployment for deployment with id ${deployment.id} not found`);
|
||||
// If the canonical deployment is not present then query the chain for the deployment record for backward compatibility
|
||||
if (!canonicalDeployment) {
|
||||
log(`Canonical deployment for deployment with id ${deployment.id} not found, querying the chain..`);
|
||||
const currentDeploymentURL = `https://${(deployment.project.name).toLowerCase()}.${deployment.deployer.baseDomain}`;
|
||||
|
||||
return false;
|
||||
}
|
||||
const deploymentRecords =
|
||||
await this.laconicRegistry.getDeploymentRecordsByFilter({
|
||||
application: deployment.applicationRecordId,
|
||||
url: currentDeploymentURL,
|
||||
});
|
||||
|
||||
if (!deploymentRecords.length) {
|
||||
log(
|
||||
`No ApplicationDeploymentRecord found for URL ${currentDeploymentURL} and ApplicationDeploymentRecord id ${deployment.applicationDeploymentRecordId}`,
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Multiple records are fetched, take the latest record
|
||||
const latestRecord = deploymentRecords
|
||||
.sort((a, b) => new Date(b.createTime).getTime() - new Date(a.createTime).getTime())[0];
|
||||
|
||||
const dnsResult =
|
||||
await this.laconicRegistry.createApplicationDeploymentRemovalRequest({
|
||||
deploymentId: dnsDeployment.applicationDeploymentRecordId!,
|
||||
deployerLrn: dnsDeployment.deployer.deployerLrn,
|
||||
auctionId: dnsDeployment.project.auctionId,
|
||||
payment: dnsDeployment.project.txHash
|
||||
deploymentId: latestRecord.id,
|
||||
deployerLrn: deployment.deployer.deployerLrn,
|
||||
auctionId: deployment.project.auctionId,
|
||||
payment: deployment.project.txHash
|
||||
});
|
||||
} else {
|
||||
// If canonical deployment is found in the DB, then send the removal request with that deployment record Id
|
||||
const result =
|
||||
await this.laconicRegistry.createApplicationDeploymentRemovalRequest({
|
||||
deploymentId: canonicalDeployment.applicationDeploymentRecordId!,
|
||||
deployerLrn: canonicalDeployment.deployer.deployerLrn,
|
||||
auctionId: canonicalDeployment.project.auctionId,
|
||||
payment: canonicalDeployment.project.txHash
|
||||
});
|
||||
|
||||
await this.db.updateDeploymentById(dnsDeployment.id, {
|
||||
status: DeploymentStatus.Deleting,
|
||||
applicationDeploymentRemovalRequestId:
|
||||
dnsResult.applicationDeploymentRemovalRequestId,
|
||||
applicationDeploymentRemovalRequestData:
|
||||
dnsResult.applicationDeploymentRemovalRequestData,
|
||||
});
|
||||
await this.db.updateDeploymentById(canonicalDeployment.id, {
|
||||
status: DeploymentStatus.Deleting,
|
||||
applicationDeploymentRemovalRequestId:
|
||||
result.applicationDeploymentRemovalRequestId,
|
||||
applicationDeploymentRemovalRequestData:
|
||||
result.applicationDeploymentRemovalRequestData,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const result =
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import { CopyBlock, atomOneLight } from 'react-code-blocks';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import { Modal } from 'components/shared/Modal';
|
||||
import { Button } from 'components/shared/Button';
|
||||
|
||||
interface AssignDomainProps {
|
||||
open: boolean;
|
||||
handleOpen: () => void;
|
||||
}
|
||||
|
||||
const AssignDomainDialog = ({ open, handleOpen }: AssignDomainProps) => {
|
||||
return (
|
||||
<Modal open={open} onOpenChange={handleOpen}>
|
||||
<Modal.Content>
|
||||
<Modal.Header>Assign Domain</Modal.Header>
|
||||
<Modal.Body>
|
||||
In order to assign a domain to your production deployments, configure
|
||||
it in the{' '}
|
||||
{/* TODO: Fix selection of project settings tab on navigation to domains */}
|
||||
<Link to="../settings/domains" className="text-light-blue-800 inline">
|
||||
project settings{' '}
|
||||
</Link>
|
||||
(recommended). If you want to assign to this specific deployment,
|
||||
however, you can do so using our command-line interface:
|
||||
{/* https://github.com/rajinwonderland/react-code-blocks/issues/138 */}
|
||||
<CopyBlock
|
||||
text="snowball alias <deployment> <domain>"
|
||||
language=""
|
||||
showLineNumbers={false}
|
||||
theme={atomOneLight}
|
||||
/>
|
||||
</Modal.Body>
|
||||
<Modal.Footer className="flex justify-start">
|
||||
<Button onClick={handleOpen}>Okay</Button>
|
||||
</Modal.Footer>
|
||||
</Modal.Content>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default AssignDomainDialog;
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
import { Deployment, Domain, Environment, Project } from 'gql-client';
|
||||
import { Button } from 'components/shared/Button';
|
||||
import {
|
||||
GlobeIcon,
|
||||
HorizontalDotIcon,
|
||||
LinkIcon,
|
||||
RefreshIcon,
|
||||
@@ -18,7 +17,6 @@ import {
|
||||
UndoIcon,
|
||||
CrossCircleIcon,
|
||||
} from 'components/shared/CustomIcon';
|
||||
import AssignDomainDialog from './AssignDomainDialog';
|
||||
import { useGQLClient } from 'context/GQLClientContext';
|
||||
import { cn } from 'utils/classnames';
|
||||
import { ChangeStateToProductionDialog } from 'components/projects/Dialog/ChangeStateToProductionDialog';
|
||||
@@ -49,8 +47,8 @@ export const DeploymentMenu = ({
|
||||
const [redeployToProduction, setRedeployToProduction] = useState(false);
|
||||
const [deleteDeploymentDialog, setDeleteDeploymentDialog] = useState(false);
|
||||
const [isConfirmDeleteLoading, setIsConfirmDeleteLoading] = useState(false);
|
||||
const [isConfirmUpdateLoading, setIsConfirmUpdateLoading] = useState(false);
|
||||
const [rollbackDeployment, setRollbackDeployment] = useState(false);
|
||||
const [assignDomainDialog, setAssignDomainDialog] = useState(false);
|
||||
const [isConfirmButtonLoading, setConfirmButtonLoadingLoading] =
|
||||
useState(false);
|
||||
|
||||
@@ -58,6 +56,8 @@ export const DeploymentMenu = ({
|
||||
const isUpdated = await client.updateDeploymentToProd(deployment.id);
|
||||
if (isUpdated.updateDeploymentToProd) {
|
||||
await onUpdate();
|
||||
setIsConfirmUpdateLoading(false);
|
||||
|
||||
toast({
|
||||
id: 'deployment_changed_to_production',
|
||||
title: 'Deployment changed to production',
|
||||
@@ -99,9 +99,12 @@ export const DeploymentMenu = ({
|
||||
const isRollbacked = await client.rollbackDeployment(
|
||||
project.id,
|
||||
deployment.id,
|
||||
deployment.deployer.deployerLrn
|
||||
);
|
||||
if (isRollbacked.rollbackDeployment) {
|
||||
await onUpdate();
|
||||
setIsConfirmUpdateLoading(false);
|
||||
|
||||
toast({
|
||||
id: 'deployment_rolled_back',
|
||||
title: 'Deployment rolled back',
|
||||
@@ -173,12 +176,6 @@ export const DeploymentMenu = ({
|
||||
<LinkIcon /> Visit
|
||||
</a>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
className="hover:bg-base-bg-emphasized flex items-center gap-3"
|
||||
onClick={() => setAssignDomainDialog(!assignDomainDialog)}
|
||||
>
|
||||
<GlobeIcon /> Assign domain
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
className="hover:bg-base-bg-emphasized flex items-center gap-3"
|
||||
onClick={() => setChangeToProduction(!changeToProduction)}
|
||||
@@ -226,9 +223,11 @@ export const DeploymentMenu = ({
|
||||
handleCancel={() => setChangeToProduction((preVal) => !preVal)}
|
||||
open={changeToProduction}
|
||||
handleConfirm={async () => {
|
||||
setIsConfirmUpdateLoading(true);
|
||||
await updateDeployment();
|
||||
setChangeToProduction((preVal) => !preVal);
|
||||
}}
|
||||
isConfirmButtonLoading={isConfirmUpdateLoading}
|
||||
deployment={deployment}
|
||||
domains={prodBranchDomains}
|
||||
/>
|
||||
@@ -243,7 +242,7 @@ export const DeploymentMenu = ({
|
||||
setRedeployToProduction((preVal) => !preVal);
|
||||
}}
|
||||
deployment={deployment}
|
||||
domains={deployment.domain ? [deployment.domain] : []}
|
||||
domains={prodBranchDomains}
|
||||
isConfirmButtonLoading={isConfirmButtonLoading}
|
||||
/>
|
||||
{Boolean(currentDeployment) && (
|
||||
@@ -253,18 +252,16 @@ export const DeploymentMenu = ({
|
||||
open={rollbackDeployment}
|
||||
confirmButtonTitle="Rollback"
|
||||
handleConfirm={async () => {
|
||||
setIsConfirmUpdateLoading(true);
|
||||
await rollbackDeploymentHandler();
|
||||
setRollbackDeployment((preVal) => !preVal);
|
||||
}}
|
||||
deployment={currentDeployment}
|
||||
newDeployment={deployment}
|
||||
domains={currentDeployment.domain ? [currentDeployment.domain] : []}
|
||||
domains={prodBranchDomains}
|
||||
isConfirmButtonLoading={isConfirmUpdateLoading}
|
||||
/>
|
||||
)}
|
||||
<AssignDomainDialog
|
||||
open={assignDomainDialog}
|
||||
handleOpen={() => setAssignDomainDialog(!assignDomainDialog)}
|
||||
/>
|
||||
<DeleteDeploymentDialog
|
||||
open={deleteDeploymentDialog}
|
||||
handleConfirm={async () => {
|
||||
|
||||
@@ -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,
|
||||
@@ -21,15 +22,6 @@ import { ChangeStateToProductionDialog } from 'components/projects/Dialog/Change
|
||||
|
||||
const deployment: Deployment = {
|
||||
id: '1',
|
||||
domain: {
|
||||
id: 'domain1',
|
||||
branch: 'main',
|
||||
name: 'example.com',
|
||||
status: DomainStatus.Live,
|
||||
redirectTo: null,
|
||||
createdAt: '1677609600', // 2023-02-25T12:00:00Z
|
||||
updatedAt: '1677613200', // 2023-02-25T13:00:00Z
|
||||
},
|
||||
branch: 'main',
|
||||
commitHash: 'a1b2c3d',
|
||||
commitMessage:
|
||||
@@ -59,6 +51,7 @@ const deployment: Deployment = {
|
||||
applicationDeploymentRequestId:
|
||||
'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize',
|
||||
applicationDeploymentRecordData: {} as AppDeploymentRecordAttributes,
|
||||
dnsRecordData: {} as DNSRecordAttributes,
|
||||
};
|
||||
|
||||
const domains: Domain[] = [
|
||||
@@ -254,7 +247,7 @@ const ModalsPage: React.FC = () => {
|
||||
setRedeployToProduction((preVal) => !preVal)
|
||||
}
|
||||
deployment={deployment}
|
||||
domains={deployment.domain ? [deployment.domain] : []}
|
||||
domains={domains}
|
||||
/>
|
||||
{/* Rollback to this deployment */}
|
||||
<Button onClick={() => setRollbackDeployment(true)}>
|
||||
@@ -270,7 +263,7 @@ const ModalsPage: React.FC = () => {
|
||||
}
|
||||
deployment={deployment}
|
||||
newDeployment={deployment}
|
||||
domains={deployment.domain ? [deployment.domain] : []}
|
||||
domains={domains}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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 = {
|
||||
@@ -100,7 +101,6 @@ export const deployment0: Deployment = {
|
||||
environment: Environment.Development,
|
||||
isCurrent: true,
|
||||
commitHash: 'Commit Hash',
|
||||
domain: domain0,
|
||||
commitMessage: 'Commit Message',
|
||||
createdBy: user,
|
||||
deployer: {
|
||||
@@ -113,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,19 +62,19 @@ query ($projectId: String!) {
|
||||
}
|
||||
deployer {
|
||||
baseDomain
|
||||
}
|
||||
domain {
|
||||
status
|
||||
branch
|
||||
createdAt
|
||||
updatedAt
|
||||
id
|
||||
name
|
||||
deployerLrn
|
||||
}
|
||||
createdBy {
|
||||
id
|
||||
name
|
||||
}
|
||||
dnsRecordData {
|
||||
name
|
||||
value
|
||||
request
|
||||
resourceType
|
||||
version
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,14 +118,6 @@ query ($organizationSlug: String!) {
|
||||
applicationDeploymentRecordData {
|
||||
url
|
||||
}
|
||||
domain {
|
||||
status
|
||||
branch
|
||||
createdAt
|
||||
updatedAt
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,14 +139,6 @@ export const getDeployments = gql`
|
||||
query ($projectId: String!) {
|
||||
deployments(projectId: $projectId) {
|
||||
id
|
||||
domain{
|
||||
branch
|
||||
createdAt
|
||||
id
|
||||
name
|
||||
status
|
||||
updatedAt
|
||||
}
|
||||
branch
|
||||
commitHash
|
||||
commitMessage
|
||||
|
||||
@@ -99,7 +99,6 @@ export type User = {
|
||||
|
||||
export type Deployment = {
|
||||
id: string;
|
||||
domain: Domain;
|
||||
branch: string;
|
||||
commitHash: string;
|
||||
commitMessage: string;
|
||||
@@ -113,6 +112,7 @@ export type Deployment = {
|
||||
createdBy: User;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
dnsRecordData: DNSRecordAttributes;
|
||||
applicationDeploymentRequestId: string;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user