From 9fb72ba0bc2295d18785b7015bb2809ae837b1dd Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Mon, 14 Oct 2024 12:03:52 +0530 Subject: [PATCH] Update Import project flow to configure deployment --- packages/backend/src/entity/Project.ts | 2 +- packages/backend/src/service.ts | 1 + .../components/projects/create/Configure.tsx | 104 ++++++++++++------ .../ProjectRepoCard/ProjectRepoCard.tsx | 41 ++----- .../pages/org-slug/projects/create/routes.tsx | 11 +- packages/gql-client/dist/index.js | 2 +- packages/gql-client/dist/index.js.map | 2 +- packages/gql-client/dist/index.mjs | 2 +- packages/gql-client/dist/index.mjs.map | 2 +- packages/gql-client/src/mutations.ts | 2 +- 10 files changed, 96 insertions(+), 73 deletions(-) diff --git a/packages/backend/src/entity/Project.ts b/packages/backend/src/entity/Project.ts index 0cdbdfc2..ea44483f 100644 --- a/packages/backend/src/entity/Project.ts +++ b/packages/backend/src/entity/Project.ts @@ -67,7 +67,7 @@ export class Project { @Column('varchar') icon!: string; - @Column('varchar', { nullable: true }) + @Column({ type: 'simple-array', nullable: true }) baseDomains!: string[] | null; @CreateDateColumn() diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index 38259953..0f3a1bbd 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -299,6 +299,7 @@ export class Service { auctionId: Not(IsNull()), }, relations: ['deployments'], + withDeleted: true, }); // Should only check on the first deployment diff --git a/packages/frontend/src/components/projects/create/Configure.tsx b/packages/frontend/src/components/projects/create/Configure.tsx index 244b814c..551dcf40 100644 --- a/packages/frontend/src/components/projects/create/Configure.tsx +++ b/packages/frontend/src/components/projects/create/Configure.tsx @@ -26,7 +26,7 @@ const Configure = () => { const [searchParams] = useSearchParams(); const templateId = searchParams.get('templateId'); const location = useLocation(); - const { templateOwner, templateRepo, owner, name, isPrivate, orgSlug } = location.state || {}; + const { templateOwner, templateRepo, owner, name, isPrivate, orgSlug, repository } = location.state || {}; const navigate = useNavigate(); const { toast, dismiss } = useToast(); @@ -47,14 +47,6 @@ const Configure = () => { setIsLoading(true); try { - const projectData: any = { - templateOwner, - templateRepo, - owner, - name, - isPrivate - }; - let lrn: string | undefined; let auctionData: AuctionData | undefined; @@ -63,26 +55,57 @@ const Configure = () => { } else if (data.option === 'Auction') { auctionData = { numProviders: Number(data.numProviders!), - maxPrice: (data.maxPrice!).toString() + maxPrice: (data.maxPrice!).toString(), }; } - const { addProjectFromTemplate } = await client.addProjectFromTemplate( - orgSlug, - projectData, - lrn, - auctionData - ); + if (templateId) { + // Template-based project creation + const projectData: any = { + templateOwner, + templateRepo, + owner, + name, + isPrivate, + }; - data.option === 'Auction' - ? navigate( - `/${orgSlug}/projects/create/success/${addProjectFromTemplate.id}`, + const { addProjectFromTemplate } = await client.addProjectFromTemplate( + orgSlug, + projectData, + lrn, + auctionData + ); + + data.option === 'Auction' + ? navigate( + `/${orgSlug}/projects/create/success/${addProjectFromTemplate.id}`, + { state: { isAuction: true } } + ) + : navigate( + `/${orgSlug}/projects/create/template/deploy?projectId=${addProjectFromTemplate.id}&templateId=${templateId}` + ); + } else { + const { addProject } = await client.addProject( + orgSlug, { - state: { - isAuction: true - } - }) - : navigate(`/${orgSlug}/projects/create/template/deploy?projectId=${addProjectFromTemplate.id}&templateId=${templateId}`); + name: repository.fullName, + prodBranch: repository.defaultBranch, + repository: repository.fullName, + template: 'webapp', + }, + lrn, + auctionData + ); + + data.option === 'Auction' + ? navigate( + `/${orgSlug}/projects/create/success/${addProject.id}`, + { state: { isAuction: true } } + ) + : navigate( + `/${orgSlug}/projects/create/deploy?projectId=${addProject.id}` + ); + } } catch (error) { console.error('Error creating project:', error); toast({ @@ -106,7 +129,9 @@ const Configure = () => { Configure deployment - The app can be deployed by setting the deployer LRN for a single deployment or by creating a deployer auction for multiple deployments + The app can be deployed by setting the deployer LRN for a single + deployment or by creating a deployer auction for multiple + deployments @@ -119,11 +144,14 @@ const Configure = () => { control={control} render={({ field: { value, onChange } }) => (