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

This commit is contained in:
Neeraj 2024-10-22 16:17:13 +05:30
parent 1f7379e561
commit 75cc73f1d1

View File

@ -68,7 +68,9 @@ const DeploymentDetailsCard = ({
prodBranchDomains,
}: DeployDetailsCardProps) => {
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 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' });
handleOpenDialog();
if (res.ok) {
const logs = await res.text();
setDeploymentLogs(logs);
handleOpenDialog();
}
}, [
deployment.deployer.deployerApiUrl,
deployment.applicationDeploymentRequestId,