1
1
import { type Interpolation , type Theme } from "@emotion/react" ;
2
- import Link , { LinkProps } from "@mui/material/Link" ;
2
+ import Link , { type LinkProps } from "@mui/material/Link" ;
3
+ import IconButton from "@mui/material/IconButton" ;
4
+ import RemoveIcon from "@mui/icons-material/RemoveOutlined" ;
5
+ import AddIcon from "@mui/icons-material/AddOutlined" ;
6
+ import Tooltip from "@mui/material/Tooltip" ;
7
+ import { visuallyHidden } from "@mui/utils" ;
8
+ import { type Dayjs } from "dayjs" ;
3
9
import { forwardRef , type FC , useRef } from "react" ;
10
+ import { useMutation , useQueryClient } from "react-query" ;
4
11
import { Link as RouterLink } from "react-router-dom" ;
5
12
import { isWorkspaceOn } from "utils/workspace" ;
6
- import type { Workspace } from "api/typesGenerated" ;
13
+ import type { Template , Workspace } from "api/typesGenerated" ;
7
14
import {
8
15
autostartDisplay ,
9
16
autostopDisplay ,
@@ -12,28 +19,22 @@ import {
12
19
getMaxDeadlineChange ,
13
20
getMinDeadline ,
14
21
} from "utils/schedule" ;
15
- import IconButton from "@mui/material/IconButton" ;
16
- import RemoveIcon from "@mui/icons-material/RemoveOutlined" ;
17
- import AddIcon from "@mui/icons-material/AddOutlined" ;
18
- import Tooltip from "@mui/material/Tooltip" ;
19
- import _ from "lodash" ;
20
22
import { getErrorMessage } from "api/errors" ;
21
23
import {
22
24
updateDeadline ,
23
25
workspaceByOwnerAndNameKey ,
24
26
} from "api/queries/workspaces" ;
25
27
import { displayError , displaySuccess } from "components/GlobalSnackbar/utils" ;
26
- import { useMutation , useQueryClient } from "react-query" ;
27
- import { Dayjs } from "dayjs" ;
28
- import { visuallyHidden } from "@mui/utils" ;
29
28
30
29
export interface WorkspaceScheduleControlsProps {
31
30
workspace : Workspace ;
31
+ template : Template ;
32
32
canUpdateSchedule : boolean ;
33
33
}
34
34
35
35
export const WorkspaceScheduleControls : FC < WorkspaceScheduleControlsProps > = ( {
36
36
workspace,
37
+ template,
37
38
canUpdateSchedule,
38
39
} ) => {
39
40
const queryClient = useQueryClient ( ) ;
@@ -90,7 +91,7 @@ export const WorkspaceScheduleControls: FC<WorkspaceScheduleControlsProps> = ({
90
91
return (
91
92
< div css = { styles . scheduleValue } data-testid = "schedule-controls" >
92
93
{ isWorkspaceOn ( workspace ) ? (
93
- < AutoStopDisplay workspace = { workspace } />
94
+ < AutoStopDisplay workspace = { workspace } template = { template } />
94
95
) : (
95
96
< ScheduleSettingsLink >
96
97
Starts at { autostartDisplay ( workspace . autostart_schedule ) }
@@ -133,22 +134,24 @@ export const WorkspaceScheduleControls: FC<WorkspaceScheduleControlsProps> = ({
133
134
134
135
interface AutoStopDisplayProps {
135
136
workspace : Workspace ;
137
+ template : Template ;
136
138
}
137
139
138
- const AutoStopDisplay : FC < AutoStopDisplayProps > = ( { workspace } ) => {
139
- const display = autostopDisplay ( workspace ) ;
140
+ const AutoStopDisplay : FC < AutoStopDisplayProps > = ( { workspace, template } ) => {
141
+ const display = autostopDisplay ( workspace , template ) ;
140
142
141
143
if ( display . tooltip ) {
142
144
return (
143
145
< Tooltip title = { display . tooltip } >
144
146
< ScheduleSettingsLink
145
- css = { ( theme ) => ( {
146
- color : isShutdownSoon ( workspace )
147
- ? `${ theme . palette . warning . light } !important`
148
- : undefined ,
149
- } ) }
147
+ css = {
148
+ isShutdownSoon ( workspace ) &&
149
+ ( ( theme ) => ( {
150
+ color : `${ theme . palette . warning . light } !important` ,
151
+ } ) )
152
+ }
150
153
>
151
- Stop { display . message }
154
+ { display . message }
152
155
</ ScheduleSettingsLink >
153
156
</ Tooltip >
154
157
) ;
0 commit comments