Skip to content

Commit a952148

Browse files
committed
Frontend implementation
1 parent c0a01ec commit a952148

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

site/src/components/Workspace/Workspace.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { ImpendingDeletionBanner } from "components/WorkspaceDeletion"
3131
import { useLocalStorage } from "hooks"
3232
import { ChooseOne, Cond } from "components/Conditionals/ChooseOne"
3333
import AlertTitle from "@mui/material/AlertTitle"
34+
import { Maybe } from "components/Conditionals/Maybe"
3435

3536
export enum WorkspaceErrors {
3637
GET_BUILDS_ERROR = "getBuildsError",
@@ -207,6 +208,28 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
207208

208209
<TemplateVersionWarnings warnings={templateWarnings} />
209210

211+
<Maybe
212+
condition={
213+
workspace.latest_build.status === "pending" &&
214+
workspace.latest_build.job.queue_size > 0
215+
}
216+
>
217+
<Alert severity="info">
218+
<AlertTitle>Workspace build is pending</AlertTitle>
219+
<AlertDetail>
220+
<div className={styles.alertPendingInQueue}>
221+
This build job is waiting for a provisioner to become
222+
available. If you have been waiting for an extended period,
223+
contact your administrator for assistance.
224+
</div>
225+
<div>
226+
Position in queue:{" "}
227+
<strong>{workspace.latest_build.job.queue_position}</strong>
228+
</div>
229+
</AlertDetail>
230+
</Alert>
231+
</Maybe>
232+
210233
{failedBuildLogs && (
211234
<Stack>
212235
<Alert
@@ -319,5 +342,9 @@ export const useStyles = makeStyles((theme) => {
319342
fullWidth: {
320343
width: "100%",
321344
},
345+
346+
alertPendingInQueue: {
347+
marginBottom: 12,
348+
},
322349
}
323350
})

site/src/components/WorkspaceStatusBadge/WorkspaceStatusBadge.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const WorkspaceStatusBadge: FC<
2020
> = ({ workspace, className }) => {
2121
const { text, icon, type } = getDisplayWorkspaceStatus(
2222
workspace.latest_build.status,
23+
workspace.latest_build.job,
2324
)
2425
return (
2526
<ChooseOne>
@@ -42,6 +43,8 @@ export const WorkspaceStatusText: FC<
4243
workspace.latest_build.status,
4344
)
4445

46+
workspace.latest_build.job.queue_size
47+
4548
return (
4649
<ChooseOne>
4750
{/* <ImpendingDeletionText/> determines its own visibility */}

site/src/components/WorkspacesTable/WorkspacesTable.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const Language = {
1313
template: "Template",
1414
lastUsed: "Last Used",
1515
status: "Status",
16-
lastBuiltBy: "Last Built By",
1716
}
1817

1918
export interface WorkspacesTableProps {

site/src/utils/workspace.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ export const getDisplayWorkspaceTemplateName = (
194194

195195
export const getDisplayWorkspaceStatus = (
196196
workspaceStatus: TypesGen.WorkspaceStatus,
197+
provisionerJob?: TypesGen.ProvisionerJob,
197198
) => {
198199
const { t } = i18next
199200

@@ -260,12 +261,23 @@ export const getDisplayWorkspaceStatus = (
260261
case "pending":
261262
return {
262263
type: "info",
263-
text: t("workspaceStatus.pending", { ns: "common" }),
264+
text: getPendingWorkspaceStatusText(provisionerJob),
264265
icon: <QueuedIcon />,
265266
} as const
266267
}
267268
}
268269

270+
const getPendingWorkspaceStatusText = (
271+
provisionerJob?: TypesGen.ProvisionerJob,
272+
): string => {
273+
const { t } = i18next
274+
275+
if (provisionerJob === undefined || provisionerJob.queue_size === 0) {
276+
return t("workspaceStatus.pending", { ns: "common" })
277+
}
278+
return "Pending in queue: " + provisionerJob.queue_position
279+
}
280+
269281
const LoadingIcon = () => {
270282
return <CircularProgress size={10} style={{ color: "#FFF" }} />
271283
}

0 commit comments

Comments
 (0)