1
- import IconButton from "@material-ui/core/IconButton"
2
1
import Link from "@material-ui/core/Link"
3
2
import { makeStyles } from "@material-ui/core/styles"
4
- import Tooltip from "@material-ui/core/Tooltip"
5
- import Typography from "@material-ui/core/Typography"
6
- import AddBoxIcon from "@material-ui/icons/AddBox"
7
- import IndeterminateCheckBoxIcon from "@material-ui/icons/IndeterminateCheckBox"
8
- import ScheduleIcon from "@material-ui/icons/Schedule"
9
3
import cronstrue from "cronstrue"
10
4
import dayjs from "dayjs"
11
5
import advancedFormat from "dayjs/plugin/advancedFormat"
@@ -37,8 +31,8 @@ export const Language = {
37
31
return "Manual"
38
32
}
39
33
} ,
40
- autoStartLabel : "START " ,
41
- autoStopLabel : "SHUTDOWN " ,
34
+ autoStartLabel : "Starts at " ,
35
+ autoStopLabel : "Stops at " ,
42
36
autoStopDisplay : ( workspace : Workspace ) : string => {
43
37
const deadline = dayjs ( workspace . latest_build . deadline ) . utc ( )
44
38
// a manual shutdown has a deadline of '"0001-01-01T00:00:00Z"'
@@ -70,80 +64,26 @@ export const Language = {
70
64
}
71
65
} ,
72
66
editScheduleLink : "Edit schedule" ,
73
- editDeadlineMinus : "Subtract one hour" ,
74
- editDeadlinePlus : "Add one hour" ,
75
- scheduleHeader : ( workspace : Workspace ) : string => {
76
- const tz = workspace . autostart_schedule
77
- ? extractTimezone ( workspace . autostart_schedule )
78
- : dayjs . tz . guess ( )
79
- return `Schedule (${ tz } )`
80
- } ,
67
+ timezoneLabel : "Timezone" ,
81
68
}
82
69
83
70
export interface WorkspaceScheduleProps {
84
- now ?: dayjs . Dayjs
85
71
workspace : Workspace
86
- onDeadlinePlus : ( ) => void
87
- onDeadlineMinus : ( ) => void
88
- }
89
-
90
- export const shouldDisplayPlusMinus = ( workspace : Workspace ) : boolean => {
91
- if ( ! isWorkspaceOn ( workspace ) ) {
92
- return false
93
- }
94
- const deadline = dayjs ( workspace . latest_build . deadline ) . utc ( )
95
- return deadline . year ( ) > 1
96
- }
97
-
98
- export const deadlineMinusDisabled = ( workspace : Workspace , now : dayjs . Dayjs ) : boolean => {
99
- const delta = dayjs ( workspace . latest_build . deadline ) . diff ( now )
100
- return delta <= 30 * 60 * 1000 // 30 minutes
101
- }
102
-
103
- export const deadlinePlusDisabled = ( workspace : Workspace , now : dayjs . Dayjs ) : boolean => {
104
- const delta = dayjs ( workspace . latest_build . deadline ) . diff ( now )
105
- return delta >= 24 * 60 * 60 * 1000 // 24 hours
106
72
}
107
73
108
- export const WorkspaceSchedule : FC < WorkspaceScheduleProps > = ( {
109
- now,
110
- workspace,
111
- onDeadlineMinus,
112
- onDeadlinePlus,
113
- } ) => {
74
+ export const WorkspaceSchedule : FC < WorkspaceScheduleProps > = ( { workspace } ) => {
114
75
const styles = useStyles ( )
115
- const editDeadlineButtons = shouldDisplayPlusMinus ( workspace ) ? (
116
- < Stack direction = "row" spacing = { 0 } >
117
- < IconButton
118
- size = "small"
119
- disabled = { deadlineMinusDisabled ( workspace , now ?? dayjs ( ) ) }
120
- className = { styles . editDeadline }
121
- onClick = { onDeadlineMinus }
122
- >
123
- < Tooltip title = { Language . editDeadlineMinus } >
124
- < IndeterminateCheckBoxIcon />
125
- </ Tooltip >
126
- </ IconButton >
127
- < IconButton
128
- size = "small"
129
- disabled = { deadlinePlusDisabled ( workspace , now ?? dayjs ( ) ) }
130
- className = { styles . editDeadline }
131
- onClick = { onDeadlinePlus }
132
- >
133
- < Tooltip title = { Language . editDeadlinePlus } >
134
- < AddBoxIcon />
135
- </ Tooltip >
136
- </ IconButton >
137
- </ Stack >
138
- ) : null
76
+ const timezone = workspace . autostart_schedule
77
+ ? extractTimezone ( workspace . autostart_schedule )
78
+ : dayjs . tz . guess ( )
139
79
140
80
return (
141
81
< div className = { styles . schedule } >
142
82
< Stack spacing = { 2 } >
143
- < Typography variant = "body1" className = { styles . title } >
144
- < ScheduleIcon className = { styles . scheduleIcon } / >
145
- { Language . scheduleHeader ( workspace ) }
146
- </ Typography >
83
+ < div >
84
+ < span className = { styles . scheduleLabel } > { Language . timezoneLabel } </ span >
85
+ < span className = { styles . scheduleValue } > { timezone } </ span >
86
+ </ div >
147
87
< div >
148
88
< span className = { styles . scheduleLabel } > { Language . autoStartLabel } </ span >
149
89
< span className = { [ styles . scheduleValue , "chromatic-ignore" ] . join ( " " ) } >
@@ -156,7 +96,6 @@ export const WorkspaceSchedule: FC<WorkspaceScheduleProps> = ({
156
96
< span className = { [ styles . scheduleValue , "chromatic-ignore" ] . join ( " " ) } >
157
97
{ Language . autoStopDisplay ( workspace ) }
158
98
</ span >
159
- { editDeadlineButtons }
160
99
</ Stack >
161
100
</ div >
162
101
< div >
@@ -177,18 +116,6 @@ const useStyles = makeStyles((theme) => ({
177
116
schedule : {
178
117
fontFamily : MONOSPACE_FONT_FAMILY ,
179
118
} ,
180
- title : {
181
- fontWeight : 600 ,
182
-
183
- fontFamily : "inherit" ,
184
- display : "flex" ,
185
- alignItems : "center" ,
186
- } ,
187
- scheduleIcon : {
188
- width : 16 ,
189
- height : 16 ,
190
- marginRight : theme . spacing ( 1 ) ,
191
- } ,
192
119
scheduleLabel : {
193
120
fontSize : 12 ,
194
121
textTransform : "uppercase" ,
@@ -198,14 +125,11 @@ const useStyles = makeStyles((theme) => ({
198
125
} ,
199
126
scheduleValue : {
200
127
fontSize : 14 ,
201
- marginTop : theme . spacing ( 0.75 ) ,
128
+ marginTop : theme . spacing ( 0.5 ) ,
202
129
display : "inline-block" ,
203
130
color : theme . palette . text . secondary ,
204
131
} ,
205
132
scheduleAction : {
206
133
cursor : "pointer" ,
207
134
} ,
208
- editDeadline : {
209
- color : theme . palette . text . secondary ,
210
- } ,
211
135
} ) )
0 commit comments