Skip to content

Commit 8f6040d

Browse files
committed
Move outdated to notifications array
1 parent c969df5 commit 8f6040d

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

site/src/pages/WorkspacePage/WorkspaceNotifications.tsx

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ import AlertTitle from "@mui/material/AlertTitle";
22
import Button from "@mui/material/Button";
33
import { workspaceResolveAutostart } from "api/queries/workspaceQuota";
44
import { Template, TemplateVersion, Workspace } from "api/typesGenerated";
5-
import { Alert, AlertDetail } from "components/Alert/Alert";
5+
import { Alert, AlertDetail, AlertProps } from "components/Alert/Alert";
66
import { FC, useEffect, useState } from "react";
77
import { useQuery } from "react-query";
88
import { WorkspacePermissions } from "./permissions";
99
import { DormantWorkspaceBanner } from "./DormantWorkspaceBanner";
1010
import dayjs from "dayjs";
1111

12+
type Notification = {
13+
title: string;
14+
severity: AlertProps["severity"];
15+
detail?: string;
16+
actions?: { label: string; onClick: () => void }[];
17+
};
18+
1219
type WorkspaceNotificationsProps = {
1320
workspace: Workspace;
1421
template: Template;
@@ -27,6 +34,7 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = (
2734
permissions,
2835
onRestartWorkspace,
2936
} = props;
37+
const notifications: Notification[] = [];
3038

3139
// Outdated
3240
const canAutostartResponse = useQuery(
@@ -40,6 +48,23 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = (
4048
const autoStartFailing = workspace.autostart_schedule && !canAutostart;
4149
const requiresManualUpdate = updateRequired && autoStartFailing;
4250

51+
if (workspace.outdated && latestVersion) {
52+
if (requiresManualUpdate) {
53+
notifications.push({
54+
title: "Autostart has been disabled for your workspace.",
55+
severity: "warning",
56+
detail:
57+
"Autostart is unable to automatically update your workspace. Manually update your workspace to reenable Autostart.",
58+
});
59+
} else {
60+
notifications.push({
61+
title: "An update is available for your workspace",
62+
severity: "info",
63+
detail: latestVersion.message,
64+
});
65+
}
66+
}
67+
4368
// Pending in Queue
4469
const [showAlertPendingInQueue, setShowAlertPendingInQueue] = useState(false);
4570
// 2023-11-15 - MES - This effect will be called every single render because
@@ -79,25 +104,6 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = (
79104

80105
return (
81106
<>
82-
{workspace.outdated &&
83-
latestVersion &&
84-
(requiresManualUpdate ? (
85-
<Alert severity="warning">
86-
<AlertTitle>
87-
Autostart has been disabled for your workspace.
88-
</AlertTitle>
89-
<AlertDetail>
90-
Autostart is unable to automatically update your workspace.
91-
Manually update your workspace to reenable Autostart.
92-
</AlertDetail>
93-
</Alert>
94-
) : (
95-
<Alert severity="info">
96-
<AlertTitle>An update is available for your workspace</AlertTitle>
97-
<AlertDetail>{latestVersion.message}</AlertDetail>
98-
</Alert>
99-
))}
100-
101107
{workspace.latest_build.status === "running" &&
102108
!workspace.health.healthy && (
103109
<Alert

0 commit comments

Comments
 (0)