@@ -2,13 +2,20 @@ import AlertTitle from "@mui/material/AlertTitle";
2
2
import Button from "@mui/material/Button" ;
3
3
import { workspaceResolveAutostart } from "api/queries/workspaceQuota" ;
4
4
import { Template , TemplateVersion , Workspace } from "api/typesGenerated" ;
5
- import { Alert , AlertDetail } from "components/Alert/Alert" ;
5
+ import { Alert , AlertDetail , AlertProps } from "components/Alert/Alert" ;
6
6
import { FC , useEffect , useState } from "react" ;
7
7
import { useQuery } from "react-query" ;
8
8
import { WorkspacePermissions } from "./permissions" ;
9
9
import { DormantWorkspaceBanner } from "./DormantWorkspaceBanner" ;
10
10
import dayjs from "dayjs" ;
11
11
12
+ type Notification = {
13
+ title : string ;
14
+ severity : AlertProps [ "severity" ] ;
15
+ detail ?: string ;
16
+ actions ?: { label : string ; onClick : ( ) => void } [ ] ;
17
+ } ;
18
+
12
19
type WorkspaceNotificationsProps = {
13
20
workspace : Workspace ;
14
21
template : Template ;
@@ -27,6 +34,7 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = (
27
34
permissions,
28
35
onRestartWorkspace,
29
36
} = props ;
37
+ const notifications : Notification [ ] = [ ] ;
30
38
31
39
// Outdated
32
40
const canAutostartResponse = useQuery (
@@ -40,6 +48,23 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = (
40
48
const autoStartFailing = workspace . autostart_schedule && ! canAutostart ;
41
49
const requiresManualUpdate = updateRequired && autoStartFailing ;
42
50
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
+
43
68
// Pending in Queue
44
69
const [ showAlertPendingInQueue , setShowAlertPendingInQueue ] = useState ( false ) ;
45
70
// 2023-11-15 - MES - This effect will be called every single render because
@@ -79,25 +104,6 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = (
79
104
80
105
return (
81
106
< >
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
-
101
107
{ workspace . latest_build . status === "running" &&
102
108
! workspace . health . healthy && (
103
109
< Alert
0 commit comments