Display build logs only when available (#10)
All checks were successful
Lint / lint (20.x) (push) Successful in 4m53s

Part of [Service provider auctions for web deployments](https://www.notion.so/Service-provider-auctions-for-web-deployments-104a6b22d47280dbad51d28aa3a91d75)

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Co-authored-by: Neeraj <neeraj.rtly@gmail.com>
Reviewed-on: #10
This commit is contained in:
nabarun 2024-10-22 12:43:20 +00:00
parent 27ef859075
commit 096318cf13
7 changed files with 39 additions and 16 deletions

View File

@ -144,6 +144,7 @@ export class Database {
.leftJoinAndSelect('deployments.createdBy', 'user') .leftJoinAndSelect('deployments.createdBy', 'user')
.leftJoinAndSelect('deployments.domain', 'domain') .leftJoinAndSelect('deployments.domain', 'domain')
.leftJoinAndSelect('project.owner', 'owner') .leftJoinAndSelect('project.owner', 'owner')
.leftJoinAndSelect('project.deployers', 'deployers')
.leftJoinAndSelect('project.organization', 'organization') .leftJoinAndSelect('project.organization', 'organization')
.where('project.id = :projectId', { .where('project.id = :projectId', {
projectId projectId

View File

@ -72,7 +72,7 @@ type Project {
repository: String! repository: String!
prodBranch: String! prodBranch: String!
description: String description: String
deployerLrns: [String] deployers: [Deployer!]
auctionId: String auctionId: String
fundsReleased: Boolean fundsReleased: Boolean
template: String template: String

View File

@ -68,7 +68,9 @@ const DeploymentDetailsCard = ({
prodBranchDomains, prodBranchDomains,
}: DeployDetailsCardProps) => { }: DeployDetailsCardProps) => {
const [openDialog, setOpenDialog] = useState<boolean>(false); const [openDialog, setOpenDialog] = useState<boolean>(false);
const [deploymentLogs, setDeploymentLogs] = useState<string>(); const [deploymentLogs, setDeploymentLogs] = useState<string>(
'No deployment logs available',
);
const handleOpenDialog = () => setOpenDialog(true); const handleOpenDialog = () => setOpenDialog(true);
const handleCloseDialog = () => setOpenDialog(false); const handleCloseDialog = () => setOpenDialog(false);
@ -92,9 +94,11 @@ const DeploymentDetailsCard = ({
const fetchDeploymentLogs = useCallback(async () => { const fetchDeploymentLogs = useCallback(async () => {
let url = `${deployment.deployer.deployerApiUrl}/log/${deployment.applicationDeploymentRequestId}`; let url = `${deployment.deployer.deployerApiUrl}/log/${deployment.applicationDeploymentRequestId}`;
const res = await fetch(url, { cache: 'no-store' }); const res = await fetch(url, { cache: 'no-store' });
const logs = await res.text();
setDeploymentLogs(logs);
handleOpenDialog(); handleOpenDialog();
if (res.ok) {
const logs = await res.text();
setDeploymentLogs(logs);
}
}, [ }, [
deployment.deployer.deployerApiUrl, deployment.deployer.deployerApiUrl,
deployment.applicationDeploymentRequestId, deployment.applicationDeploymentRequestId,

View File

@ -1,5 +1,5 @@
import { useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
import { Auction, Project } from 'gql-client'; import { Auction, Deployer, Project } from 'gql-client';
import { import {
Dialog, Dialog,
@ -19,7 +19,7 @@ const WAIT_DURATION = 5000;
export const AuctionCard = ({ project }: { project: Project }) => { export const AuctionCard = ({ project }: { project: Project }) => {
const [auctionStatus, setAuctionStatus] = useState<string>(''); const [auctionStatus, setAuctionStatus] = useState<string>('');
const [deployerLrns, setDeployerLrns] = useState<string[]>([]); const [deployers, setDeployers] = useState<Deployer[]>([]);
const [fundsStatus, setFundsStatus] = useState<boolean>(false); const [fundsStatus, setFundsStatus] = useState<boolean>(false);
const [auctionDetails, setAuctionDetails] = useState<Auction | null>(null); const [auctionDetails, setAuctionDetails] = useState<Auction | null>(null);
const [openDialog, setOpenDialog] = useState<boolean>(false); const [openDialog, setOpenDialog] = useState<boolean>(false);
@ -36,7 +36,7 @@ export const AuctionCard = ({ project }: { project: Project }) => {
const result = await client.getAuctionData(project.auctionId); const result = await client.getAuctionData(project.auctionId);
setAuctionStatus(result.status); setAuctionStatus(result.status);
setAuctionDetails(result); setAuctionDetails(result);
setDeployerLrns(project.deployerLrns); setDeployers(project.deployers);
setFundsStatus(project.fundsReleased); 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 // Wait for 5 secs since the project is not immediately updated with deployer LRNs
await new Promise((resolve) => setTimeout(resolve, WAIT_DURATION)); await new Promise((resolve) => setTimeout(resolve, WAIT_DURATION));
const updatedProject = await client.getProject(project.id); const updatedProject = await client.getProject(project.id);
setDeployerLrns(updatedProject.project?.deployerLrns || []); setDeployers(updatedProject.project?.deployers || []);
}; };
fetchUpdatedProject(); fetchUpdatedProject();
} }
@ -102,14 +102,14 @@ export const AuctionCard = ({ project }: { project: Project }) => {
</span> </span>
</div> </div>
{deployerLrns?.length > 0 && ( {deployers?.length > 0 && (
<div className="mt-3"> <div className="mt-3">
<span className="text-elements-high-em text-sm font-medium tracking-tight"> <span className="text-elements-high-em text-sm font-medium tracking-tight">
Deployer LRNs Deployer LRNs
</span> </span>
{deployerLrns.map((lrn, index) => ( {deployers.map((deployer, index) => (
<p key={index} className="text-elements-mid-em text-sm"> <p key={index} className="text-elements-mid-em text-sm">
{'\u2022'} {lrn} {'\u2022'} {deployer.deployerLrn}
</p> </p>
))} ))}
</div> </div>

View File

@ -127,7 +127,13 @@ export const project: Project = {
template: 'Template', template: 'Template',
members: [member], members: [member],
auctionId: '7553538436710373822151221341b43f577e07b0525d083cc9b2de98890138a1', 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'], webhooks: ['beepboop'],
icon: 'Icon', icon: 'Icon',
fundsReleased: true, fundsReleased: true,

View File

@ -24,7 +24,11 @@ query ($projectId: String!) {
updatedAt updatedAt
prodBranch prodBranch
auctionId auctionId
deployerLrns deployers {
deployerApiUrl
deployerId
deployerLrn
}
fundsReleased fundsReleased
framework framework
repository repository
@ -76,7 +80,11 @@ query ($organizationSlug: String!) {
description description
framework framework
auctionId auctionId
deployerLrns deployers {
deployerApiUrl
deployerId
deployerLrn
}
fundsReleased fundsReleased
prodBranch prodBranch
webhooks webhooks
@ -199,7 +207,11 @@ query ($searchText: String!) {
description description
framework framework
auctionId auctionId
deployerLrns deployers {
deployerApiUrl
deployerId
deployerLrn
}
fundsReleased fundsReleased
prodBranch prodBranch
webhooks webhooks

View File

@ -176,7 +176,7 @@ export type Project = {
description: string; description: string;
template: string; template: string;
framework: string; framework: string;
deployerLrns: string[]; deployers: [Deployer]
auctionId: string; auctionId: string;
fundsReleased: boolean; fundsReleased: boolean;
webhooks: string[]; webhooks: string[];