From a952148e10cea8cfc949b7026ac424b7fb16330f Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 28 Jun 2023 13:19:35 +0200 Subject: [PATCH 1/4] Frontend implementation --- site/src/components/Workspace/Workspace.tsx | 27 +++++++++++++++++++ .../WorkspaceStatusBadge.tsx | 3 +++ .../WorkspacesTable/WorkspacesTable.tsx | 1 - site/src/utils/workspace.tsx | 14 +++++++++- 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/site/src/components/Workspace/Workspace.tsx b/site/src/components/Workspace/Workspace.tsx index 6c743673546f6..b89437fb7ea97 100644 --- a/site/src/components/Workspace/Workspace.tsx +++ b/site/src/components/Workspace/Workspace.tsx @@ -31,6 +31,7 @@ import { ImpendingDeletionBanner } from "components/WorkspaceDeletion" import { useLocalStorage } from "hooks" import { ChooseOne, Cond } from "components/Conditionals/ChooseOne" import AlertTitle from "@mui/material/AlertTitle" +import { Maybe } from "components/Conditionals/Maybe" export enum WorkspaceErrors { GET_BUILDS_ERROR = "getBuildsError", @@ -207,6 +208,28 @@ export const Workspace: FC> = ({ + 0 + } + > + + Workspace build is pending + +
+ This build job is waiting for a provisioner to become + available. If you have been waiting for an extended period, + contact your administrator for assistance. +
+
+ Position in queue:{" "} + {workspace.latest_build.job.queue_position} +
+
+
+
+ {failedBuildLogs && ( { fullWidth: { width: "100%", }, + + alertPendingInQueue: { + marginBottom: 12, + }, } }) diff --git a/site/src/components/WorkspaceStatusBadge/WorkspaceStatusBadge.tsx b/site/src/components/WorkspaceStatusBadge/WorkspaceStatusBadge.tsx index ec50d9d7404b0..9a746d421b906 100644 --- a/site/src/components/WorkspaceStatusBadge/WorkspaceStatusBadge.tsx +++ b/site/src/components/WorkspaceStatusBadge/WorkspaceStatusBadge.tsx @@ -20,6 +20,7 @@ export const WorkspaceStatusBadge: FC< > = ({ workspace, className }) => { const { text, icon, type } = getDisplayWorkspaceStatus( workspace.latest_build.status, + workspace.latest_build.job, ) return ( @@ -42,6 +43,8 @@ export const WorkspaceStatusText: FC< workspace.latest_build.status, ) + workspace.latest_build.job.queue_size + return ( {/* determines its own visibility */} diff --git a/site/src/components/WorkspacesTable/WorkspacesTable.tsx b/site/src/components/WorkspacesTable/WorkspacesTable.tsx index 796d768b5a97b..71c31312f8df4 100644 --- a/site/src/components/WorkspacesTable/WorkspacesTable.tsx +++ b/site/src/components/WorkspacesTable/WorkspacesTable.tsx @@ -13,7 +13,6 @@ const Language = { template: "Template", lastUsed: "Last Used", status: "Status", - lastBuiltBy: "Last Built By", } export interface WorkspacesTableProps { diff --git a/site/src/utils/workspace.tsx b/site/src/utils/workspace.tsx index 7c009daa8f6fd..20c360acd9578 100644 --- a/site/src/utils/workspace.tsx +++ b/site/src/utils/workspace.tsx @@ -194,6 +194,7 @@ export const getDisplayWorkspaceTemplateName = ( export const getDisplayWorkspaceStatus = ( workspaceStatus: TypesGen.WorkspaceStatus, + provisionerJob?: TypesGen.ProvisionerJob, ) => { const { t } = i18next @@ -260,12 +261,23 @@ export const getDisplayWorkspaceStatus = ( case "pending": return { type: "info", - text: t("workspaceStatus.pending", { ns: "common" }), + text: getPendingWorkspaceStatusText(provisionerJob), icon: , } as const } } +const getPendingWorkspaceStatusText = ( + provisionerJob?: TypesGen.ProvisionerJob, +): string => { + const { t } = i18next + + if (provisionerJob === undefined || provisionerJob.queue_size === 0) { + return t("workspaceStatus.pending", { ns: "common" }) + } + return "Pending in queue: " + provisionerJob.queue_position +} + const LoadingIcon = () => { return } From 5c72bce9e15e3936cde94e0c6db2d194fdaf7c2b Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 28 Jun 2023 13:32:42 +0200 Subject: [PATCH 2/4] Storybook changes --- site/src/components/Workspace/Workspace.stories.tsx | 7 +++++++ .../pages/WorkspacesPage/WorkspacesPageView.stories.tsx | 5 +++++ site/src/testHelpers/entities.ts | 2 ++ 3 files changed, 14 insertions(+) diff --git a/site/src/components/Workspace/Workspace.stories.tsx b/site/src/components/Workspace/Workspace.stories.tsx index a0137fa458fab..0950b03f1edd3 100644 --- a/site/src/components/Workspace/Workspace.stories.tsx +++ b/site/src/components/Workspace/Workspace.stories.tsx @@ -98,6 +98,13 @@ export const WithoutUpdateAccess: Story = { }, } +export const PendingInQueue: Story = { + args: { + ...Running.args, + workspace: Mocks.MockPendingWorkspace, + }, +} + export const Starting: Story = { args: { ...Running.args, diff --git a/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx b/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx index d325e49970477..ed032cb99f6f5 100644 --- a/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx +++ b/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx @@ -15,6 +15,7 @@ import { MockExperiments, mockApiError, MockUser, + MockPendingProvisionerJob, } from "testHelpers/entities" import { WorkspacesPageView } from "./WorkspacesPageView" import { DashboardProviderContext } from "components/Dashboard/DashboardProvider" @@ -33,6 +34,10 @@ const createWorkspace = ( latest_build: { ...MockWorkspace.latest_build, status, + job: + status === "pending" + ? MockPendingProvisionerJob + : MockWorkspace.latest_build.job, }, last_used_at: lastUsedAt, } diff --git a/site/src/testHelpers/entities.ts b/site/src/testHelpers/entities.ts index c76f91ccefb2a..e0507ea27ff66 100644 --- a/site/src/testHelpers/entities.ts +++ b/site/src/testHelpers/entities.ts @@ -310,6 +310,8 @@ export const MockRunningProvisionerJob: TypesGen.ProvisionerJob = { export const MockPendingProvisionerJob: TypesGen.ProvisionerJob = { ...MockProvisionerJob, status: "pending", + queue_position: 2, + queue_size: 4, } export const MockTemplateVersion: TypesGen.TemplateVersion = { id: "test-template-version", From e530f7df27c4776ea83080969e586f3c2f1517c7 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 28 Jun 2023 13:35:19 +0200 Subject: [PATCH 3/4] fix: Position in queue --- site/src/utils/workspace.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/src/utils/workspace.tsx b/site/src/utils/workspace.tsx index 20c360acd9578..993f20477f365 100644 --- a/site/src/utils/workspace.tsx +++ b/site/src/utils/workspace.tsx @@ -275,7 +275,7 @@ const getPendingWorkspaceStatusText = ( if (provisionerJob === undefined || provisionerJob.queue_size === 0) { return t("workspaceStatus.pending", { ns: "common" }) } - return "Pending in queue: " + provisionerJob.queue_position + return "Position in queue: " + provisionerJob.queue_position } const LoadingIcon = () => { From efe4928e709063132979ae10b1390eae4af95524 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 28 Jun 2023 14:07:16 +0200 Subject: [PATCH 4/4] Address PR feedback --- site/src/components/Workspace/Workspace.tsx | 7 ++++--- .../WorkspaceStatusBadge/WorkspaceStatusBadge.tsx | 2 -- site/src/utils/workspace.tsx | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/site/src/components/Workspace/Workspace.tsx b/site/src/components/Workspace/Workspace.tsx index b89437fb7ea97..7b08798c74d54 100644 --- a/site/src/components/Workspace/Workspace.tsx +++ b/site/src/components/Workspace/Workspace.tsx @@ -218,9 +218,10 @@ export const Workspace: FC> = ({ Workspace build is pending
- This build job is waiting for a provisioner to become - available. If you have been waiting for an extended period, - contact your administrator for assistance. + This workspace build job is waiting for a provisioner to + become available. If you have been waiting for an extended + period of time, please contact your administrator for + assistance.
Position in queue:{" "} diff --git a/site/src/components/WorkspaceStatusBadge/WorkspaceStatusBadge.tsx b/site/src/components/WorkspaceStatusBadge/WorkspaceStatusBadge.tsx index 9a746d421b906..7f742dab2ff3c 100644 --- a/site/src/components/WorkspaceStatusBadge/WorkspaceStatusBadge.tsx +++ b/site/src/components/WorkspaceStatusBadge/WorkspaceStatusBadge.tsx @@ -43,8 +43,6 @@ export const WorkspaceStatusText: FC< workspace.latest_build.status, ) - workspace.latest_build.job.queue_size - return ( {/* determines its own visibility */} diff --git a/site/src/utils/workspace.tsx b/site/src/utils/workspace.tsx index 993f20477f365..f366eaa21a2cd 100644 --- a/site/src/utils/workspace.tsx +++ b/site/src/utils/workspace.tsx @@ -272,7 +272,7 @@ const getPendingWorkspaceStatusText = ( ): string => { const { t } = i18next - if (provisionerJob === undefined || provisionerJob.queue_size === 0) { + if (!provisionerJob || provisionerJob.queue_size === 0) { return t("workspaceStatus.pending", { ns: "common" }) } return "Position in queue: " + provisionerJob.queue_position