From 96c00cc37188ddb9fd1cedfb7c687659ab75fc97 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Thu, 24 Oct 2024 11:21:18 +0530 Subject: [PATCH] Display deployment status if logs are not available --- .../components/projects/create/DeployStep.tsx | 12 +++++------ .../deployments/DeploymentDetailsCard.tsx | 20 +++++++++++++------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/packages/frontend/src/components/projects/create/DeployStep.tsx b/packages/frontend/src/components/projects/create/DeployStep.tsx index 4c674df8..4ee5e5c2 100644 --- a/packages/frontend/src/components/projects/create/DeployStep.tsx +++ b/packages/frontend/src/components/projects/create/DeployStep.tsx @@ -21,12 +21,7 @@ interface DeployStepsProps { processTime?: string; } -const DeployStep = ({ - step, - status, - title, - startTime, -}: DeployStepsProps) => { +const DeployStep = ({ step, status, title, startTime }: DeployStepsProps) => { return (
)} {status === DeployStatus.COMPLETE && ( diff --git a/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx b/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx index cac7e6d1..5dbabfee 100644 --- a/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx +++ b/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx @@ -93,12 +93,20 @@ const DeploymentDetailsCard = ({ }; const fetchDeploymentLogs = async () => { - let url = `${deployment.deployer.deployerApiUrl}/log/${deployment.applicationDeploymentRequestId}`; - const res = await fetch(url, { cache: 'no-store' }); - handleOpenDialog(); - if (res.ok) { - const logs = await res.text(); - setDeploymentLogs(logs); + const statusUrl = `${deployment.deployer.deployerApiUrl}/${deployment.applicationDeploymentRequestId}`; + const statusRes = await fetch(statusUrl, { cache: 'no-store' }).then( + (res) => res.json(), + ); + if (!statusRes.logAvailable) { + setDeploymentLogs(statusRes.lastState); + handleOpenDialog(); + } else { + const logsUrl = `${deployment.deployer.deployerApiUrl}/log/${deployment.applicationDeploymentRequestId}`; + const logsRes = await fetch(logsUrl, { cache: 'no-store' }).then((res) => + res.text(), + ); + setDeploymentLogs(logsRes); + handleOpenDialog(); } };