@@ -15,42 +15,44 @@ import { Stack } from "../Stack/Stack"
15
15
dayjs . extend ( duration )
16
16
dayjs . extend ( relativeTime )
17
17
18
- const autoStartLabel = ( schedule : string ) : string => {
19
- const prefix = "Start"
20
-
21
- if ( schedule ) {
22
- return `${ prefix } (${ extractTimezone ( schedule ) } )`
23
- } else {
24
- return prefix
25
- }
26
- }
27
-
28
- const autoStartDisplay = ( schedule : string ) : string => {
29
- if ( schedule ) {
30
- return cronstrue . toString ( stripTimezone ( schedule ) , { throwExceptionOnParseError : false } )
31
- }
32
- return "Manual"
33
- }
18
+ const Language = {
19
+ autoStartDisplay : ( schedule : string ) : string => {
20
+ if ( schedule ) {
21
+ return cronstrue . toString ( stripTimezone ( schedule ) , { throwExceptionOnParseError : false } )
22
+ }
23
+ return "Manual"
24
+ } ,
25
+ autoStartLabel : ( schedule : string ) : string => {
26
+ const prefix = "Start"
34
27
35
- const autoStopDisplay = ( workspace : Workspace ) : string => {
36
- const latest = workspace . latest_build
28
+ if ( schedule ) {
29
+ return `${ prefix } (${ extractTimezone ( schedule ) } )`
30
+ } else {
31
+ return prefix
32
+ }
33
+ } ,
34
+ autoStopDisplay : ( workspace : Workspace ) : string => {
35
+ const latest = workspace . latest_build
37
36
38
- if ( ! workspace . ttl || workspace . ttl < 1 ) {
39
- return "Manual"
40
- }
37
+ if ( ! workspace . ttl || workspace . ttl < 1 ) {
38
+ return "Manual"
39
+ }
41
40
42
- if ( latest . transition === "start" ) {
43
- const now = dayjs ( )
44
- const updatedAt = dayjs ( latest . updated_at )
45
- const deadline = updatedAt . add ( workspace . ttl / 1_000_000 , "ms" )
46
- if ( now . isAfter ( deadline ) ) {
47
- return "Workspace is shutting down now"
41
+ if ( latest . transition === "start" ) {
42
+ const now = dayjs ( )
43
+ const updatedAt = dayjs ( latest . updated_at )
44
+ const deadline = updatedAt . add ( workspace . ttl / 1_000_000 , "ms" )
45
+ if ( now . isAfter ( deadline ) ) {
46
+ return "Workspace is shutting down now"
47
+ }
48
+ return now . to ( deadline )
48
49
}
49
- return now . to ( deadline )
50
- }
51
50
52
- const duration = dayjs . duration ( workspace . ttl / 1_000_000 , "milliseconds" )
53
- return `${ duration . humanize ( ) } after start`
51
+ const duration = dayjs . duration ( workspace . ttl / 1_000_000 , "milliseconds" )
52
+ return `${ duration . humanize ( ) } after start`
53
+ } ,
54
+ editScheduleLink : "Edit schedule" ,
55
+ schedule : "Schedule" ,
54
56
}
55
57
56
58
export interface WorkspaceScheduleProps {
@@ -65,18 +67,18 @@ export const WorkspaceSchedule: React.FC<WorkspaceScheduleProps> = ({ workspace
65
67
< Stack spacing = { 2 } >
66
68
< Typography variant = "body1" className = { styles . title } >
67
69
< ScheduleIcon className = { styles . scheduleIcon } />
68
- Schedule
70
+ { Language . schedule }
69
71
</ Typography >
70
72
< div >
71
- < span className = { styles . scheduleLabel } > { autoStartLabel ( workspace . autostart_schedule ) } </ span >
72
- < span className = { styles . scheduleValue } > { autoStartDisplay ( workspace . autostart_schedule ) } </ span >
73
+ < span className = { styles . scheduleLabel } > { Language . autoStartLabel ( workspace . autostart_schedule ) } </ span >
74
+ < span className = { styles . scheduleValue } > { Language . autoStartDisplay ( workspace . autostart_schedule ) } </ span >
73
75
</ div >
74
76
< div >
75
77
< span className = { styles . scheduleLabel } > Shutdown</ span >
76
- < span className = { styles . scheduleValue } > { autoStopDisplay ( workspace ) } </ span >
78
+ < span className = { styles . scheduleValue } > { Language . autoStopDisplay ( workspace ) } </ span >
77
79
</ div >
78
80
< div >
79
- < Link className = { styles . scheduleAction } > Edit schedule </ Link >
81
+ < Link className = { styles . scheduleAction } > { Language . editScheduleLink } </ Link >
80
82
</ div >
81
83
</ Stack >
82
84
</ div >
0 commit comments