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

fix: ws schedule as 12-hour format#2209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
greyscaled merged 8 commits intomainfromvapurrmaid/gh-2175/12-hour-format
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletionssite/src/components/WorkspaceSchedule/WorkspaceSchedule.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,7 @@ import { FC } from "react"
import { Link as RouterLink } from "react-router-dom"
import { Workspace } from "../../api/typesGenerated"
import { MONOSPACE_FONT_FAMILY } from "../../theme/constants"
import {extractTimezone,stripTimezone } from "../../util/schedule"
import { stripTimezone } from "../../util/schedule"
import { isWorkspaceOn } from "../../util/workspace"
import { Stack } from "../Stack/Stack"

Expand All@@ -31,20 +31,11 @@ export const Language = {
return "Manual"
}
},
autoStartLabel: (schedule: string | undefined): string => {
const prefix = "Start"
const timezone = schedule ? extractTimezone(schedule) : dayjs.tz.guess()

if (schedule) {
return `${prefix} (${dayjs().tz(timezone).format("z")})`
} else {
return prefix
}
},
autoStartLabel: "START",
autoStopLabel: "SHUTDOWN",
autoStopDisplay: (workspace: Workspace): string => {
const schedule = workspace.autostart_schedule
const deadline = dayjs(workspace.latest_build.deadline).utc()
// amannual shutdown has a deadline of '"0001-01-01T00:00:00Z"'
// amanual shutdown has a deadline of '"0001-01-01T00:00:00Z"'
// SEE: #1834
const hasDeadline = deadline.year() > 1
const ttl = workspace.ttl_ms
Expand All@@ -59,8 +50,7 @@ export const Language = {
if (now.isAfter(deadline)) {
return "Workspace is shutting down"
} else {
const timezone = schedule ? extractTimezone(schedule) : dayjs.tz.guess()
return deadline.tz(timezone).format("HH:mm A")
return deadline.tz(dayjs.tz.guess()).format("hh:mm A")
}
} else if (!ttl || ttl < 1) {
// If the workspace is not on, and the ttl is 0 or undefined, then the
Expand All@@ -74,7 +64,7 @@ export const Language = {
}
},
editScheduleLink: "Edit schedule",
schedule:"Schedule",
schedule:`Schedule (${dayjs.tz.guess()})`,
}

export interface WorkspaceScheduleProps {
Expand All@@ -92,11 +82,13 @@ export const WorkspaceSchedule: FC<WorkspaceScheduleProps> = ({ workspace }) =>
{Language.schedule}
</Typography>
<div>
<span className={styles.scheduleLabel}>{Language.autoStartLabel(workspace.autostart_schedule)}</span>
<span className={styles.scheduleValue}>{Language.autoStartDisplay(workspace.autostart_schedule)}</span>
<span className={styles.scheduleLabel}>{Language.autoStartLabel}</span>
<span className={styles.scheduleValue} data-chromatic="ignore">
{Language.autoStartDisplay(workspace.autostart_schedule)}
</span>
</div>
<div>
<span className={styles.scheduleLabel}>Shutdown</span>
<span className={styles.scheduleLabel}>{Language.autoStopLabel}</span>
<span className={styles.scheduleValue} data-chromatic="ignore">
{Language.autoStopDisplay(workspace)}
</span>
Expand Down
4 changes: 3 additions & 1 deletionsite/src/pages/WorkspacePage/WorkspacePage.test.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -43,7 +43,9 @@ const renderWorkspacePage = async () => {

const testButton = async (label: string, actionMock: jest.SpyInstance) => {
await renderWorkspacePage()
const button = await screen.findByText(label)
// REMARK: exact here because the "Start" button and "START" label for
// workspace schedule could otherwise conflict.
const button = await screen.findByText(label, { exact: true })
await waitFor(() => fireEvent.click(button))
expect(actionMock).toBeCalled()
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp