Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb0d5203

Browse files
authored
refactor: resource strings in WorkspaceSchedule (#1702)
1 parentc7ca86d commitb0d5203

File tree

1 file changed

+38
-36
lines changed

1 file changed

+38
-36
lines changed

‎site/src/components/WorkspaceSchedule/WorkspaceSchedule.tsx

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,44 @@ import { Stack } from "../Stack/Stack"
1515
dayjs.extend(duration)
1616
dayjs.extend(relativeTime)
1717

18-
constautoStartLabel=(schedule:string):string=>{
19-
constprefix="Start"
20-
21-
if(schedule){
22-
return`${prefix} (${extractTimezone(schedule)})`
23-
}else{
24-
returnprefix
25-
}
26-
}
27-
28-
constautoStartDisplay=(schedule:string):string=>{
29-
if(schedule){
30-
returncronstrue.toString(stripTimezone(schedule),{throwExceptionOnParseError:false})
31-
}
32-
return"Manual"
33-
}
18+
constLanguage={
19+
autoStartDisplay:(schedule:string):string=>{
20+
if(schedule){
21+
returncronstrue.toString(stripTimezone(schedule),{throwExceptionOnParseError:false})
22+
}
23+
return"Manual"
24+
},
25+
autoStartLabel:(schedule:string):string=>{
26+
constprefix="Start"
3427

35-
constautoStopDisplay=(workspace:Workspace):string=>{
36-
constlatest=workspace.latest_build
28+
if(schedule){
29+
return`${prefix} (${extractTimezone(schedule)})`
30+
}else{
31+
returnprefix
32+
}
33+
},
34+
autoStopDisplay:(workspace:Workspace):string=>{
35+
constlatest=workspace.latest_build
3736

38-
if(!workspace.ttl||workspace.ttl<1){
39-
return"Manual"
40-
}
37+
if(!workspace.ttl||workspace.ttl<1){
38+
return"Manual"
39+
}
4140

42-
if(latest.transition==="start"){
43-
constnow=dayjs()
44-
constupdatedAt=dayjs(latest.updated_at)
45-
constdeadline=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+
constnow=dayjs()
43+
constupdatedAt=dayjs(latest.updated_at)
44+
constdeadline=updatedAt.add(workspace.ttl/1_000_000,"ms")
45+
if(now.isAfter(deadline)){
46+
return"Workspace is shutting down now"
47+
}
48+
returnnow.to(deadline)
4849
}
49-
returnnow.to(deadline)
50-
}
5150

52-
constduration=dayjs.duration(workspace.ttl/1_000_000,"milliseconds")
53-
return`${duration.humanize()} after start`
51+
constduration=dayjs.duration(workspace.ttl/1_000_000,"milliseconds")
52+
return`${duration.humanize()} after start`
53+
},
54+
editScheduleLink:"Edit schedule",
55+
schedule:"Schedule",
5456
}
5557

5658
exportinterfaceWorkspaceScheduleProps{
@@ -65,18 +67,18 @@ export const WorkspaceSchedule: React.FC<WorkspaceScheduleProps> = ({ workspace
6567
<Stackspacing={2}>
6668
<Typographyvariant="body1"className={styles.title}>
6769
<ScheduleIconclassName={styles.scheduleIcon}/>
68-
Schedule
70+
{Language.schedule}
6971
</Typography>
7072
<div>
71-
<spanclassName={styles.scheduleLabel}>{autoStartLabel(workspace.autostart_schedule)}</span>
72-
<spanclassName={styles.scheduleValue}>{autoStartDisplay(workspace.autostart_schedule)}</span>
73+
<spanclassName={styles.scheduleLabel}>{Language.autoStartLabel(workspace.autostart_schedule)}</span>
74+
<spanclassName={styles.scheduleValue}>{Language.autoStartDisplay(workspace.autostart_schedule)}</span>
7375
</div>
7476
<div>
7577
<spanclassName={styles.scheduleLabel}>Shutdown</span>
76-
<spanclassName={styles.scheduleValue}>{autoStopDisplay(workspace)}</span>
78+
<spanclassName={styles.scheduleValue}>{Language.autoStopDisplay(workspace)}</span>
7779
</div>
7880
<div>
79-
<LinkclassName={styles.scheduleAction}>Edit schedule</Link>
81+
<LinkclassName={styles.scheduleAction}>{Language.editScheduleLink}</Link>
8082
</div>
8183
</Stack>
8284
</div>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp