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

refactor: resource strings in WorkspaceSchedule#1702

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 1 commit intomainfromvapurrmaid/language
May 24, 2022
Merged
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
74 changes: 38 additions & 36 deletionssite/src/components/WorkspaceSchedule/WorkspaceSchedule.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,42 +15,44 @@ import { Stack } from "../Stack/Stack"
dayjs.extend(duration)
dayjs.extend(relativeTime)

const autoStartLabel = (schedule: string): string => {
const prefix = "Start"

if (schedule) {
return `${prefix} (${extractTimezone(schedule)})`
} else {
return prefix
}
}

const autoStartDisplay = (schedule: string): string => {
if (schedule) {
return cronstrue.toString(stripTimezone(schedule), { throwExceptionOnParseError: false })
}
return "Manual"
}
const Language = {
autoStartDisplay: (schedule: string): string => {
if (schedule) {
return cronstrue.toString(stripTimezone(schedule), { throwExceptionOnParseError: false })
}
return "Manual"
},
autoStartLabel: (schedule: string): string => {
const prefix = "Start"

const autoStopDisplay = (workspace: Workspace): string => {
const latest = workspace.latest_build
if (schedule) {
return `${prefix} (${extractTimezone(schedule)})`
} else {
return prefix
}
},
autoStopDisplay: (workspace: Workspace): string => {
const latest = workspace.latest_build

if (!workspace.ttl || workspace.ttl < 1) {
return "Manual"
}
if (!workspace.ttl || workspace.ttl < 1) {
return "Manual"
}

if (latest.transition === "start") {
const now = dayjs()
const updatedAt = dayjs(latest.updated_at)
const deadline = updatedAt.add(workspace.ttl / 1_000_000, "ms")
if (now.isAfter(deadline)) {
return "Workspace is shutting down now"
if (latest.transition === "start") {
const now = dayjs()
const updatedAt = dayjs(latest.updated_at)
const deadline = updatedAt.add(workspace.ttl / 1_000_000, "ms")
if (now.isAfter(deadline)) {
return "Workspace is shutting down now"
}
return now.to(deadline)
}
return now.to(deadline)
}

const duration = dayjs.duration(workspace.ttl / 1_000_000, "milliseconds")
return `${duration.humanize()} after start`
const duration = dayjs.duration(workspace.ttl / 1_000_000, "milliseconds")
return `${duration.humanize()} after start`
},
editScheduleLink: "Edit schedule",
schedule: "Schedule",
}

export interface WorkspaceScheduleProps {
Expand All@@ -65,18 +67,18 @@ export const WorkspaceSchedule: React.FC<WorkspaceScheduleProps> = ({ workspace
<Stack spacing={2}>
<Typography variant="body1" className={styles.title}>
<ScheduleIcon className={styles.scheduleIcon} />
Schedule
{Language.schedule}
</Typography>
<div>
<span className={styles.scheduleLabel}>{autoStartLabel(workspace.autostart_schedule)}</span>
<span className={styles.scheduleValue}>{autoStartDisplay(workspace.autostart_schedule)}</span>
<span className={styles.scheduleLabel}>{Language.autoStartLabel(workspace.autostart_schedule)}</span>
<span className={styles.scheduleValue}>{Language.autoStartDisplay(workspace.autostart_schedule)}</span>
</div>
<div>
<span className={styles.scheduleLabel}>Shutdown</span>
<span className={styles.scheduleValue}>{autoStopDisplay(workspace)}</span>
<span className={styles.scheduleValue}>{Language.autoStopDisplay(workspace)}</span>
</div>
<div>
<Link className={styles.scheduleAction}>Edit schedule</Link>
<Link className={styles.scheduleAction}>{Language.editScheduleLink}</Link>
</div>
</Stack>
</div>
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp