From 1f7379e56155d3b79ada5d9d57ef35445b4a3d2d Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 22 Oct 2024 16:07:34 +0530 Subject: [PATCH 1/2] Display deployer lrns in auction card --- packages/backend/src/database.ts | 1 + packages/backend/src/schema.gql | 2 +- .../project/overview/Activity/AuctionCard.tsx | 14 +++++++------- .../frontend/src/stories/MockStoriesData.ts | 8 +++++++- packages/gql-client/src/queries.ts | 18 +++++++++++++++--- packages/gql-client/src/types.ts | 2 +- 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/packages/backend/src/database.ts b/packages/backend/src/database.ts index 5b681c3f..7bcd77bc 100644 --- a/packages/backend/src/database.ts +++ b/packages/backend/src/database.ts @@ -144,6 +144,7 @@ export class Database { .leftJoinAndSelect('deployments.createdBy', 'user') .leftJoinAndSelect('deployments.domain', 'domain') .leftJoinAndSelect('project.owner', 'owner') + .leftJoinAndSelect('project.deployers', 'deployers') .leftJoinAndSelect('project.organization', 'organization') .where('project.id = :projectId', { projectId diff --git a/packages/backend/src/schema.gql b/packages/backend/src/schema.gql index 1d788b67..4a63e584 100644 --- a/packages/backend/src/schema.gql +++ b/packages/backend/src/schema.gql @@ -72,7 +72,7 @@ type Project { repository: String! prodBranch: String! description: String - deployerLrns: [String] + deployers: [Deployer!] auctionId: String fundsReleased: Boolean template: String diff --git a/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx b/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx index 5367553d..3a15caf0 100644 --- a/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx +++ b/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx @@ -1,5 +1,5 @@ import { useCallback, useEffect, useState } from 'react'; -import { Auction, Project } from 'gql-client'; +import { Auction, Deployer, Project } from 'gql-client'; import { Dialog, @@ -19,7 +19,7 @@ const WAIT_DURATION = 5000; export const AuctionCard = ({ project }: { project: Project }) => { const [auctionStatus, setAuctionStatus] = useState(''); - const [deployerLrns, setDeployerLrns] = useState([]); + const [deployers, setDeployers] = useState([]); const [fundsStatus, setFundsStatus] = useState(false); const [auctionDetails, setAuctionDetails] = useState(null); const [openDialog, setOpenDialog] = useState(false); @@ -36,7 +36,7 @@ export const AuctionCard = ({ project }: { project: Project }) => { const result = await client.getAuctionData(project.auctionId); setAuctionStatus(result.status); setAuctionDetails(result); - setDeployerLrns(project.deployerLrns); + setDeployers(project.deployers); setFundsStatus(project.fundsReleased); }, []); @@ -52,7 +52,7 @@ export const AuctionCard = ({ project }: { project: Project }) => { // Wait for 5 secs since the project is not immediately updated with deployer LRNs await new Promise((resolve) => setTimeout(resolve, WAIT_DURATION)); const updatedProject = await client.getProject(project.id); - setDeployerLrns(updatedProject.project?.deployerLrns || []); + setDeployers(updatedProject.project?.deployers || []); }; fetchUpdatedProject(); } @@ -102,14 +102,14 @@ export const AuctionCard = ({ project }: { project: Project }) => { - {deployerLrns?.length > 0 && ( + {deployers?.length > 0 && (
Deployer LRNs - {deployerLrns.map((lrn, index) => ( + {deployers.map((deployer, index) => (

- {'\u2022'} {lrn} + {'\u2022'} {deployer.deployerLrn}

))}
diff --git a/packages/frontend/src/stories/MockStoriesData.ts b/packages/frontend/src/stories/MockStoriesData.ts index be3ff31a..3d0e46f5 100644 --- a/packages/frontend/src/stories/MockStoriesData.ts +++ b/packages/frontend/src/stories/MockStoriesData.ts @@ -127,7 +127,13 @@ export const project: Project = { template: 'Template', members: [member], auctionId: '7553538436710373822151221341b43f577e07b0525d083cc9b2de98890138a1', - deployerLrns: ['lrn://deployer.apps.snowballtools.com '], + deployers: [ + { + deployerApiUrl: 'https://webapp-deployer-api.example.com', + deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu', + deployerLrn: 'lrn://deployer.apps.snowballtools.com ', + } + ], webhooks: ['beepboop'], icon: 'Icon', fundsReleased: true, diff --git a/packages/gql-client/src/queries.ts b/packages/gql-client/src/queries.ts index c41c75a4..0d2ad0f9 100644 --- a/packages/gql-client/src/queries.ts +++ b/packages/gql-client/src/queries.ts @@ -24,7 +24,11 @@ query ($projectId: String!) { updatedAt prodBranch auctionId - deployerLrns + deployers { + deployerApiUrl + deployerId + deployerLrn + } fundsReleased framework repository @@ -76,7 +80,11 @@ query ($organizationSlug: String!) { description framework auctionId - deployerLrns + deployers { + deployerApiUrl + deployerId + deployerLrn + } fundsReleased prodBranch webhooks @@ -199,7 +207,11 @@ query ($searchText: String!) { description framework auctionId - deployerLrns + deployers { + deployerApiUrl + deployerId + deployerLrn + } fundsReleased prodBranch webhooks diff --git a/packages/gql-client/src/types.ts b/packages/gql-client/src/types.ts index af46bfa5..74cf17b1 100644 --- a/packages/gql-client/src/types.ts +++ b/packages/gql-client/src/types.ts @@ -176,7 +176,7 @@ export type Project = { description: string; template: string; framework: string; - deployerLrns: string[]; + deployers: [Deployer] auctionId: string; fundsReleased: boolean; webhooks: string[]; -- 2.45.2 From 75cc73f1d1c5d8b8cfe93a6525498ee3f7c592aa Mon Sep 17 00:00:00 2001 From: Neeraj Date: Tue, 22 Oct 2024 16:17:13 +0530 Subject: [PATCH 2/2] Display build logs only when available --- .../project/deployments/DeploymentDetailsCard.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx b/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx index ea5a33a1..b8abe55b 100644 --- a/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx +++ b/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx @@ -68,7 +68,9 @@ const DeploymentDetailsCard = ({ prodBranchDomains, }: DeployDetailsCardProps) => { const [openDialog, setOpenDialog] = useState(false); - const [deploymentLogs, setDeploymentLogs] = useState(); + const [deploymentLogs, setDeploymentLogs] = useState( + 'No deployment logs available', + ); const handleOpenDialog = () => setOpenDialog(true); const handleCloseDialog = () => setOpenDialog(false); @@ -92,9 +94,11 @@ const DeploymentDetailsCard = ({ const fetchDeploymentLogs = useCallback(async () => { let url = `${deployment.deployer.deployerApiUrl}/log/${deployment.applicationDeploymentRequestId}`; const res = await fetch(url, { cache: 'no-store' }); - const logs = await res.text(); - setDeploymentLogs(logs); handleOpenDialog(); + if (res.ok) { + const logs = await res.text(); + setDeploymentLogs(logs); + } }, [ deployment.deployer.deployerApiUrl, deployment.applicationDeploymentRequestId, -- 2.45.2