@@ -3,12 +3,14 @@ import ErrorIcon from "@mui/icons-material/ErrorOutline"
3
3
import StopIcon from "@mui/icons-material/StopOutlined"
4
4
import PlayIcon from "@mui/icons-material/PlayArrowOutlined"
5
5
import QueuedIcon from "@mui/icons-material/HourglassEmpty"
6
- import { WorkspaceBuild } from "api/typesGenerated"
6
+ import { Workspace , WorkspaceBuild } from "api/typesGenerated"
7
7
import { Pill } from "components/Pill/Pill"
8
8
import i18next from "i18next"
9
9
import { FC , PropsWithChildren } from "react"
10
10
import { makeStyles } from "@mui/styles"
11
11
import { combineClasses } from "utils/combineClasses"
12
+ import { displayImpendingDeletion } from "utils/workspace"
13
+ import { useDashboard } from "components/Dashboard/DashboardProvider"
12
14
13
15
const LoadingIcon : FC = ( ) => {
14
16
return < CircularProgress size = { 10 } style = { { color : "#FFF" } } />
@@ -87,22 +89,52 @@ export const getStatus = (buildStatus: WorkspaceBuild["status"]) => {
87
89
}
88
90
89
91
export type WorkspaceStatusBadgeProps = {
90
- build : WorkspaceBuild
92
+ workspace : Workspace
91
93
className ?: string
92
94
}
93
95
96
+ const ImpendingDeletionBadge : FC < Partial < WorkspaceStatusBadgeProps > > = ( {
97
+ className,
98
+ } ) => {
99
+ const { entitlements, experiments } = useDashboard ( )
100
+ const allowAdvancedScheduling =
101
+ entitlements . features [ "advanced_template_scheduling" ] . enabled
102
+ // This check can be removed when https://github.com/coder/coder/milestone/19
103
+ // is merged up
104
+ const allowWorkspaceActions = experiments . includes ( "workspace_actions" )
105
+
106
+ if ( ! allowAdvancedScheduling || ! allowWorkspaceActions ) {
107
+ return null
108
+ }
109
+ return (
110
+ < Pill
111
+ className = { className }
112
+ icon = { < ErrorIcon /> }
113
+ text = "Impending deletion"
114
+ type = "error"
115
+ />
116
+ )
117
+ }
118
+
94
119
export const WorkspaceStatusBadge : FC <
95
120
PropsWithChildren < WorkspaceStatusBadgeProps >
96
- > = ( { build, className } ) => {
97
- const { text, icon, type } = getStatus ( build . status )
121
+ > = ( { workspace, className } ) => {
122
+ // The ImpendingDeletionBadge component itself checks to see if the
123
+ // Advanced Scheduling feature is turned on and if the
124
+ // Workspace Actions flag is turned on.
125
+ if ( displayImpendingDeletion ( workspace ) ) {
126
+ return < ImpendingDeletionBadge className = { className } />
127
+ }
128
+
129
+ const { text, icon, type } = getStatus ( workspace . latest_build . status )
98
130
return < Pill className = { className } icon = { icon } text = { text } type = { type } />
99
131
}
100
132
101
133
export const WorkspaceStatusText : FC <
102
134
PropsWithChildren < WorkspaceStatusBadgeProps >
103
- > = ( { build , className } ) => {
135
+ > = ( { workspace , className } ) => {
104
136
const styles = useStyles ( )
105
- const { text, type } = getStatus ( build . status )
137
+ const { text, type } = getStatus ( workspace . latest_build . status )
106
138
return (
107
139
< span
108
140
role = "status"
0 commit comments