Display deployment status if logs are not available

This commit is contained in:
IshaVenikar 2024-10-24 11:21:18 +05:30 committed by Adw8
parent d96a7af224
commit 96c00cc371
2 changed files with 19 additions and 13 deletions

View File

@ -21,12 +21,7 @@ interface DeployStepsProps {
processTime?: string;
}
const DeployStep = ({
step,
status,
title,
startTime,
}: DeployStepsProps) => {
const DeployStep = ({ step, status, title, startTime }: DeployStepsProps) => {
return (
<div className="border-b border-border-separator">
<button
@ -60,7 +55,10 @@ const DeployStep = ({
{status === DeployStatus.PROCESSING && (
<div className="flex items-center gap-1.5">
<ClockOutlineIcon size={16} className="text-elements-low-em" />
<Stopwatch offsetTimestamp={setStopWatchOffset(startTime!)} isPaused={false}/>
<Stopwatch
offsetTimestamp={setStopWatchOffset(startTime!)}
isPaused={false}
/>
</div>
)}
{status === DeployStatus.COMPLETE && (

View File

@ -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' });
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();
if (res.ok) {
const logs = await res.text();
setDeploymentLogs(logs);
}
};