@@ -31,6 +31,16 @@ export const shouldDisplayPlusMinus = (workspace: Workspace): boolean => {
31
31
return isWorkspaceOn ( workspace ) && Boolean ( workspace . latest_build . deadline )
32
32
}
33
33
34
+ export const shouldDisplayScheduleLabel = ( workspace : Workspace ) : boolean => {
35
+ if ( shouldDisplayPlusMinus ( workspace ) ) {
36
+ return true
37
+ }
38
+ if ( isWorkspaceOn ( workspace ) ) {
39
+ return false
40
+ }
41
+ return Boolean ( workspace . autostart_schedule )
42
+ }
43
+
34
44
export interface WorkspaceScheduleButtonProps {
35
45
workspace : Workspace
36
46
onDeadlinePlus : ( ) => void
@@ -60,41 +70,45 @@ export const WorkspaceScheduleButton: React.FC<WorkspaceScheduleButtonProps> = (
60
70
61
71
return (
62
72
< span className = { styles . wrapper } >
63
- < span className = { styles . label } >
64
- < WorkspaceScheduleLabel workspace = { workspace } />
65
- { canUpdateWorkspace && shouldDisplayPlusMinus ( workspace ) && (
66
- < span className = { styles . actions } >
67
- < IconButton
68
- className = { styles . iconButton }
69
- size = "small"
70
- disabled = { ! deadlineMinusEnabled ( ) }
71
- onClick = { onDeadlineMinus }
72
- >
73
- < Tooltip title = { t ( "workspaceScheduleButton.editDeadlineMinus" ) } >
74
- < RemoveIcon />
75
- </ Tooltip >
76
- </ IconButton >
77
- < IconButton
78
- className = { styles . iconButton }
79
- size = "small"
80
- disabled = { ! deadlinePlusEnabled ( ) }
81
- onClick = { onDeadlinePlus }
82
- >
83
- < Tooltip title = { t ( "workspaceScheduleButton.editDeadlinePlus" ) } >
84
- < AddIcon />
85
- </ Tooltip >
86
- </ IconButton >
87
- </ span >
88
- ) }
89
- </ span >
73
+ { shouldDisplayScheduleLabel ( workspace ) && (
74
+ < span className = { styles . label } >
75
+ < WorkspaceScheduleLabel workspace = { workspace } />
76
+ { canUpdateWorkspace && shouldDisplayPlusMinus ( workspace ) && (
77
+ < span className = { styles . actions } >
78
+ < IconButton
79
+ className = { styles . iconButton }
80
+ size = "small"
81
+ disabled = { ! deadlineMinusEnabled ( ) }
82
+ onClick = { onDeadlineMinus }
83
+ >
84
+ < Tooltip title = { t ( "workspaceScheduleButton.editDeadlineMinus" ) } >
85
+ < RemoveIcon />
86
+ </ Tooltip >
87
+ </ IconButton >
88
+ < IconButton
89
+ className = { styles . iconButton }
90
+ size = "small"
91
+ disabled = { ! deadlinePlusEnabled ( ) }
92
+ onClick = { onDeadlinePlus }
93
+ >
94
+ < Tooltip title = { t ( "workspaceScheduleButton.editDeadlinePlus" ) } >
95
+ < AddIcon />
96
+ </ Tooltip >
97
+ </ IconButton >
98
+ </ span >
99
+ ) }
100
+ </ span >
101
+ ) }
90
102
< >
91
103
< Button
92
104
ref = { anchorRef }
93
105
startIcon = { < ScheduleIcon /> }
94
106
onClick = { ( ) => {
95
107
setIsOpen ( true )
96
108
} }
97
- className = { styles . scheduleButton }
109
+ className = { `${ styles . scheduleButton } ${
110
+ shouldDisplayScheduleLabel ( workspace ) ? "label" : ""
111
+ } `}
98
112
>
99
113
{ t ( "workspaceScheduleButton.schedule" ) }
100
114
</ Button >
@@ -124,8 +138,8 @@ const useStyles = makeStyles((theme) => ({
124
138
wrapper : {
125
139
display : "inline-flex" ,
126
140
alignItems : "center" ,
127
- border : `1px solid ${ theme . palette . divider } ` ,
128
141
borderRadius : `${ theme . shape . borderRadius } px` ,
142
+ border : `1px solid ${ theme . palette . divider } ` ,
129
143
130
144
[ theme . breakpoints . down ( "sm" ) ] : {
131
145
flexDirection : "column" ,
@@ -153,15 +167,22 @@ const useStyles = makeStyles((theme) => ({
153
167
} ,
154
168
scheduleButton : {
155
169
border : "none" ,
156
- borderLeft : `1px solid ${ theme . palette . divider } ` ,
157
- borderRadius : `0px ${ theme . shape . borderRadius } px ${ theme . shape . borderRadius } px 0px` ,
170
+ borderRadius : `${ theme . shape . borderRadius } px` ,
158
171
flexShrink : 0 ,
159
172
173
+ "&.label" : {
174
+ borderLeft : `1px solid ${ theme . palette . divider } ` ,
175
+ borderRadius : `0px ${ theme . shape . borderRadius } px ${ theme . shape . borderRadius } px 0px` ,
176
+ } ,
177
+
160
178
[ theme . breakpoints . down ( "sm" ) ] : {
161
179
width : "100%" ,
162
- borderLeft : 0 ,
163
- borderTop : `1px solid ${ theme . palette . divider } ` ,
164
- borderRadius : `0 0 ${ theme . shape . borderRadius } px ${ theme . shape . borderRadius } px` ,
180
+
181
+ "&.label" : {
182
+ borderRadius : `0 0 ${ theme . shape . borderRadius } px ${ theme . shape . borderRadius } px` ,
183
+ borderLeft : 0 ,
184
+ borderTop : `1px solid ${ theme . palette . divider } ` ,
185
+ } ,
165
186
} ,
166
187
} ,
167
188
iconButton : {
0 commit comments