Update method for deleting deployment

This commit is contained in:
IshaVenikar 2024-10-11 12:33:25 +05:30 committed by Nabarun
parent bf75dc8acc
commit 55e238d0b9
18 changed files with 60 additions and 46 deletions

View File

@ -465,8 +465,6 @@ export class Database {
id: organizationId
});
newProject.subDomain = `${newProject.name}.${this.projectDomain}`;
return projectRepository.save(newProject);
}

View File

@ -138,6 +138,9 @@ export class Deployment {
@Column('boolean', { default: false })
isCurrent!: boolean;
@Column('varchar', { nullable: true })
baseDomain!: string | null;
@Column({
enum: DeploymentStatus
})

View File

@ -67,8 +67,8 @@ export class Project {
@Column('varchar')
icon!: string;
@Column('varchar')
subDomain!: string;
@Column('varchar', { nullable: true })
baseDomains!: string[] | null;
@CreateDateColumn()
createdAt!: Date;

View File

@ -194,7 +194,6 @@ export class Registry {
})
).data.html_url;
// TODO: Set environment variables for each deployment (environment variables can't be set in application record)
const { applicationRecordId } =
await this.createApplicationRecord({
appName: repo,
@ -421,6 +420,7 @@ export class Registry {
async createApplicationDeploymentRemovalRequest (data: {
deploymentId: string;
deployerLrn: string;
}): Promise<{
applicationDeploymentRemovalRequestId: string;
applicationDeploymentRemovalRequestData: ApplicationDeploymentRemovalRequest;
@ -428,7 +428,8 @@ export class Registry {
const applicationDeploymentRemovalRequest = {
type: APP_DEPLOYMENT_REMOVAL_REQUEST_TYPE,
version: '1.0.0',
deployment: data.deploymentId
deployment: data.deploymentId,
deployer: data.deployerLrn
};
const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees);

View File

@ -83,7 +83,7 @@ type Project {
updatedAt: String!
organization: Organization!
icon: String
subDomain: String
baseDomains: [String!]
}
type ProjectMember {
@ -105,6 +105,7 @@ type Deployment {
environment: Environment!
deployerLrn: String
isCurrent: Boolean!
baseDomain: String
status: DeploymentStatus!
createdAt: String!
updatedAt: String!

View File

@ -210,10 +210,21 @@ export class Service {
applicationDeploymentRecordId: record.id,
applicationDeploymentRecordData: record.attributes,
url: record.attributes.url,
baseDomain,
status: DeploymentStatus.Ready,
isCurrent: deployment.environment === Environment.Production,
});
const baseDomains = project.baseDomains || [];
if (!baseDomains.includes(baseDomain)) {
baseDomains.push(baseDomain);
}
await this.db.updateProjectById(project.id, {
baseDomains
})
log(
`Updated deployment ${deployment.id} with URL ${record.attributes.url}`,
);
@ -1113,7 +1124,7 @@ export class Service {
if (deployment && deployment.applicationDeploymentRecordId) {
// If deployment is current, remove deployment for project subdomain as well
if (deployment.isCurrent) {
const currentDeploymentURL = `https://${deployment.project.subDomain}`;
const currentDeploymentURL = `https://${(deployment.project.name).toLowerCase()}.${deployment.baseDomain}`;
const deploymentRecords =
await this.registry.getDeploymentRecordsByFilter({
@ -1131,12 +1142,14 @@ export class Service {
await this.registry.createApplicationDeploymentRemovalRequest({
deploymentId: deploymentRecords[0].id,
deployerLrn: deployment.deployerLrn
});
}
const result =
await this.registry.createApplicationDeploymentRemovalRequest({
deploymentId: deployment.applicationDeploymentRecordId,
deployerLrn: deployment.deployerLrn
});
await this.db.updateDeploymentById(deployment.id, {

View File

@ -73,7 +73,7 @@ async function main() {
// Remove deployment for project subdomain if deployment is for production environment
if (deployment.environment === Environment.Production) {
applicationDeploymentRecord.url = `https://${deployment.project.subDomain}`
applicationDeploymentRecord.url = `https://${deployment.project.name}.${deployment.baseDomain}`;
await registry.setRecord(
{

View File

@ -5,7 +5,6 @@ import { Badge } from 'components/shared/Badge';
import { Button } from 'components/shared/Button';
import {
ArrowLeftCircleFilledIcon,
LinkChainIcon,
QuestionMarkRoundFilledIcon,
} from 'components/shared/CustomIcon';
import { Heading } from 'components/shared/Heading';
@ -55,22 +54,6 @@ const Id = () => {
<Heading as="h3" className="font-medium text-xl">
{isAuction? 'Project created successfully.' : 'Project deployed successfully.'}
</Heading>
{!isAuction && (
<p className="flex flex-col items-center lg:flex-row font-sans gap-0.5 lg:gap-2 text-sm text-elements-high-em">
Your project has been deployed at{' '}
<Button
className="no-underline text-elements-link"
// TODO: use dynamic value
href={project ? `https://${project.subDomain}` : ''}
as="a"
variant="link-emphasized"
external
leftIcon={<LinkChainIcon />}
>
{project.subDomain}
</Button>
</p>
)}
</div>
{/* Card */}

View File

@ -129,12 +129,15 @@ const OverviewTabPanel = () => {
<Heading className="text-lg leading-6 font-medium truncate">
{project.name}
</Heading>
<a
href={`https://${project.subDomain}`}
className="text-sm text-elements-low-em tracking-tight truncate"
>
{project.subDomain}
</a>
{project.baseDomains && project.baseDomains.length > 0 && project.baseDomains.map((baseDomain, index) => (
<a
key={index}
href={`https://${project.name}.${baseDomain}`}
className="text-sm text-elements-low-em tracking-tight truncate"
>
{baseDomain}
</a>
))}
</div>
</div>
<OverviewInfo label="Domain" icon={<GlobeIcon />}>

View File

@ -102,7 +102,7 @@ export const deployment0: Deployment = {
domain: domain0,
commitMessage: 'Commit Message',
createdBy: user,
deployerLrn: 'lrn://deepstack-test4/deployers/webapp-deployer-api.test4.wireitin.com',
deployerLrn: 'lrn://deployer.apps.snowballtools.com ',
};
export const project: Project = {
@ -121,8 +121,8 @@ export const project: Project = {
template: 'Template',
members: [member],
auctionId: '7553538436710373822151221341b43f577e07b0525d083cc9b2de98890138a1',
deployerLrns: ['lrn://deepstack-test4/deployers/webapp-deployer-api.test4.wireitin.com', 'lrn://wireitin/deployers/webapp-deployer-api.wireitin.com'],
deployerLrns: ['lrn://deployer.apps.snowballtools.com '],
webhooks: ['beepboop'],
icon: 'Icon',
subDomain: 'SubDomain',
baseDomains: ['baseDomain'],
};

View File

@ -94,6 +94,7 @@ type Deployment = {
deployerLrn: string;
environment: Environment;
isCurrent: boolean;
baseDomain?: string;
status: DeploymentStatus;
createdBy: User;
createdAt: string;
@ -158,7 +159,7 @@ type Project = {
updatedAt: string;
organization: Organization;
icon: string;
subDomain: string;
baseDomains?: string[] | null;
};
type GetProjectMembersResponse = {
projectMembers: ProjectMember[];

View File

@ -94,6 +94,7 @@ type Deployment = {
deployerLrn: string;
environment: Environment;
isCurrent: boolean;
baseDomain?: string;
status: DeploymentStatus;
createdBy: User;
createdAt: string;
@ -158,7 +159,7 @@ type Project = {
updatedAt: string;
organization: Organization;
icon: string;
subDomain: string;
baseDomains?: string[] | null;
};
type GetProjectMembersResponse = {
projectMembers: ProjectMember[];

View File

@ -83,7 +83,7 @@ query ($projectId: String!) {
repository
webhooks
icon
subDomain
baseDomains
organization {
id
name
@ -97,6 +97,7 @@ query ($projectId: String!) {
id
branch
isCurrent
baseDomain
status
updatedAt
commitHash
@ -133,11 +134,12 @@ query ($organizationSlug: String!) {
repository
updatedAt
icon
subDomain
baseDomains
deployments {
id
branch
isCurrent
baseDomain
status
updatedAt
commitHash
@ -186,6 +188,7 @@ query ($projectId: String!) {
deployerLrn
environment
isCurrent
baseDomain
status
createdAt
updatedAt

File diff suppressed because one or more lines are too long

View File

@ -55,7 +55,7 @@ query ($projectId: String!) {
repository
webhooks
icon
subDomain
baseDomains
organization {
id
name
@ -69,6 +69,7 @@ query ($projectId: String!) {
id
branch
isCurrent
baseDomain
status
updatedAt
commitHash
@ -105,11 +106,12 @@ query ($organizationSlug: String!) {
repository
updatedAt
icon
subDomain
baseDomains
deployments {
id
branch
isCurrent
baseDomain
status
updatedAt
commitHash
@ -158,6 +160,7 @@ query ($projectId: String!) {
deployerLrn
environment
isCurrent
baseDomain
status
createdAt
updatedAt

File diff suppressed because one or more lines are too long

View File

@ -29,7 +29,7 @@ query ($projectId: String!) {
repository
webhooks
icon
subDomain
baseDomains
organization {
id
name
@ -43,6 +43,7 @@ query ($projectId: String!) {
id
branch
isCurrent
baseDomain
status
updatedAt
commitHash
@ -80,11 +81,12 @@ query ($organizationSlug: String!) {
repository
updatedAt
icon
subDomain
baseDomains
deployments {
id
branch
isCurrent
baseDomain
status
updatedAt
commitHash
@ -135,6 +137,7 @@ query ($projectId: String!) {
deployerLrn
environment
isCurrent
baseDomain
status
createdAt
updatedAt

View File

@ -108,6 +108,7 @@ export type Deployment = {
deployerLrn: string;
environment: Environment;
isCurrent: boolean;
baseDomain?: string;
status: DeploymentStatus;
createdBy: User;
createdAt: string;
@ -177,7 +178,7 @@ export type Project = {
updatedAt: string;
organization: Organization;
icon: string;
subDomain: string;
baseDomains?: string[] | null;
};
export type GetProjectMembersResponse = {