From ee605b34b6f7f5ccc0b1e1c37b35cb62d16c16ec Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Wed, 7 Dec 2022 10:22:20 -0600 Subject: [PATCH] fix: Don't show progress bar for new templates (#5298) --- .../WorkspaceBuildProgress.stories.tsx | 13 ++++++++++++- .../WorkspaceBuildProgress.tsx | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/site/src/components/WorkspaceBuildProgress/WorkspaceBuildProgress.stories.tsx b/site/src/components/WorkspaceBuildProgress/WorkspaceBuildProgress.stories.tsx index 23c9ecf134..3448280948 100644 --- a/site/src/components/WorkspaceBuildProgress/WorkspaceBuildProgress.stories.tsx +++ b/site/src/components/WorkspaceBuildProgress/WorkspaceBuildProgress.stories.tsx @@ -39,10 +39,21 @@ Starting.args = { }, } +// When the transition stats are returning null, the progress bar should not be +// displayed export const StartingUnknown = Template.bind({}) StartingUnknown.args = { ...Starting.args, - transitionStats: undefined, + transitionStats: { + // HACK: the codersdk type generator doesn't support null values, but this + // can be null when the template is new. + // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- Read comment above + // @ts-ignore-error + P50: null, + // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- Read comment above + // @ts-ignore-error + P95: null, + }, } export const StartingPassedEstimate = Template.bind({}) diff --git a/site/src/components/WorkspaceBuildProgress/WorkspaceBuildProgress.tsx b/site/src/components/WorkspaceBuildProgress/WorkspaceBuildProgress.tsx index 389f57e946..ed38865f21 100644 --- a/site/src/components/WorkspaceBuildProgress/WorkspaceBuildProgress.tsx +++ b/site/src/components/WorkspaceBuildProgress/WorkspaceBuildProgress.tsx @@ -102,6 +102,11 @@ export const WorkspaceBuildProgress: FC = ({ setTimeout(updateProgress, 5) }, [progressValue, job, transitionStats]) + // HACK: the codersdk type generator doesn't support null values, but this + // can be null when the template is new. + if ((transitionStats.P50 as number | null) === null) { + return <> + } return (