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

Commit411d7da

Browse files
authored
fix: ws schedule as 12-hour format (#2209)
This does not finish all tasks in#2175 but is one of the asks.
1 parent377f17c commit411d7da

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

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

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { FC } from "react"
1313
import{LinkasRouterLink}from"react-router-dom"
1414
import{Workspace}from"../../api/typesGenerated"
1515
import{MONOSPACE_FONT_FAMILY}from"../../theme/constants"
16-
import{extractTimezone,stripTimezone}from"../../util/schedule"
16+
import{stripTimezone}from"../../util/schedule"
1717
import{isWorkspaceOn}from"../../util/workspace"
1818
import{Stack}from"../Stack/Stack"
1919

@@ -31,20 +31,11 @@ export const Language = {
3131
return"Manual"
3232
}
3333
},
34-
autoStartLabel:(schedule:string|undefined):string=>{
35-
constprefix="Start"
36-
consttimezone=schedule ?extractTimezone(schedule) :dayjs.tz.guess()
37-
38-
if(schedule){
39-
return`${prefix} (${dayjs().tz(timezone).format("z")})`
40-
}else{
41-
returnprefix
42-
}
43-
},
34+
autoStartLabel:"START",
35+
autoStopLabel:"SHUTDOWN",
4436
autoStopDisplay:(workspace:Workspace):string=>{
45-
constschedule=workspace.autostart_schedule
4637
constdeadline=dayjs(workspace.latest_build.deadline).utc()
47-
// amannual shutdown has a deadline of '"0001-01-01T00:00:00Z"'
38+
// amanual shutdown has a deadline of '"0001-01-01T00:00:00Z"'
4839
// SEE: #1834
4940
consthasDeadline=deadline.year()>1
5041
constttl=workspace.ttl_ms
@@ -59,8 +50,7 @@ export const Language = {
5950
if(now.isAfter(deadline)){
6051
return"Workspace is shutting down"
6152
}else{
62-
consttimezone=schedule ?extractTimezone(schedule) :dayjs.tz.guess()
63-
returndeadline.tz(timezone).format("HH:mm A")
53+
returndeadline.tz(dayjs.tz.guess()).format("hh:mm A")
6454
}
6555
}elseif(!ttl||ttl<1){
6656
// If the workspace is not on, and the ttl is 0 or undefined, then the
@@ -74,7 +64,7 @@ export const Language = {
7464
}
7565
},
7666
editScheduleLink:"Edit schedule",
77-
schedule:"Schedule",
67+
schedule:`Schedule (${dayjs.tz.guess()})`,
7868
}
7969

8070
exportinterfaceWorkspaceScheduleProps{
@@ -92,11 +82,13 @@ export const WorkspaceSchedule: FC<WorkspaceScheduleProps> = ({ workspace }) =>
9282
{Language.schedule}
9383
</Typography>
9484
<div>
95-
<spanclassName={styles.scheduleLabel}>{Language.autoStartLabel(workspace.autostart_schedule)}</span>
96-
<spanclassName={styles.scheduleValue}>{Language.autoStartDisplay(workspace.autostart_schedule)}</span>
85+
<spanclassName={styles.scheduleLabel}>{Language.autoStartLabel}</span>
86+
<spanclassName={styles.scheduleValue}data-chromatic="ignore">
87+
{Language.autoStartDisplay(workspace.autostart_schedule)}
88+
</span>
9789
</div>
9890
<div>
99-
<spanclassName={styles.scheduleLabel}>Shutdown</span>
91+
<spanclassName={styles.scheduleLabel}>{Language.autoStopLabel}</span>
10092
<spanclassName={styles.scheduleValue}data-chromatic="ignore">
10193
{Language.autoStopDisplay(workspace)}
10294
</span>

‎site/src/pages/WorkspacePage/WorkspacePage.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ const renderWorkspacePage = async () => {
4343

4444
consttestButton=async(label:string,actionMock:jest.SpyInstance)=>{
4545
awaitrenderWorkspacePage()
46-
constbutton=awaitscreen.findByText(label)
46+
// REMARK: exact here because the "Start" button and "START" label for
47+
// workspace schedule could otherwise conflict.
48+
constbutton=awaitscreen.findByText(label,{exact:true})
4749
awaitwaitFor(()=>fireEvent.click(button))
4850
expect(actionMock).toBeCalled()
4951
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp