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

feat: ws schedule timezone select#2032

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 3 commits intomainfromvapurrmaid/gh-1959/tzdata
Jun 3, 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
1 change: 1 addition & 0 deletionssite/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,6 +48,7 @@
"react-router-dom": "6.3.0",
"sourcemapped-stacktrace": "1.1.11",
"swr": "1.2.2",
"tzdata": "1.0.30",
"uuid": "8.3.2",
"xstate": "4.32.1",
"xterm": "4.18.0",
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
import { Language, validationSchema, WorkspaceScheduleFormValues } from "./WorkspaceScheduleForm"
import { zones } from "./zones"

const valid: WorkspaceScheduleFormValues = {
sunday: false,
Expand DownExpand Up@@ -127,6 +128,15 @@ describe("validationSchema", () => {
expect(validate).toThrowError(Language.errorTimezone)
})

it.each<[string]>(zones.map((zone) => [zone]))(`validation passes for tz=%p`, (zone) => {
const values: WorkspaceScheduleFormValues = {
...valid,
timezone: zone,
}
const validate = () => validationSchema.validateSync(values)
expect(validate).not.toThrow()
})

it("allows a ttl of 7 days", () => {
const values: WorkspaceScheduleFormValues = {
...valid,
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ import FormControlLabel from "@material-ui/core/FormControlLabel"
import FormGroup from "@material-ui/core/FormGroup"
import FormHelperText from "@material-ui/core/FormHelperText"
import FormLabel from "@material-ui/core/FormLabel"
importLink from "@material-ui/core/Link"
importMenuItem from "@material-ui/core/MenuItem"
import makeStyles from "@material-ui/core/styles/makeStyles"
import TextField from "@material-ui/core/TextField"
import dayjs from "dayjs"
Expand All@@ -18,6 +18,7 @@ import { getFormHelpers } from "../../util/formUtils"
import { FormFooter } from "../FormFooter/FormFooter"
import { FullPageForm } from "../FullPageForm/FullPageForm"
import { Stack } from "../Stack/Stack"
import { zones } from "./zones"

// REMARK: timezone plugin depends on UTC
//
Expand DownExpand Up@@ -203,21 +204,20 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
/>

<TextField
{...formHelpers(
"timezone",
<>
Timezone must be a valid name from the{" "}
<Link href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List" target="_blank">
timezone database
</Link>
</>,
)}
{...formHelpers("timezone")}
disabled={isLoading}
InputLabelProps={{
shrink: true,
}}
label={Language.timezoneLabel}
/>
select
>
{zones.map((zone) => (
<MenuItem key={zone} value={zone}>
{zone}
</MenuItem>
))}
</TextField>

<FormControl component="fieldset" error={Boolean(form.errors.monday)}>
<FormLabel className={styles.daysOfWeekLabel} component="legend">
Expand Down
3 changes: 3 additions & 0 deletionssite/src/components/WorkspaceScheduleForm/zones.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
import tzData from "tzdata"

export const zones: string[] = Object.keys(tzData.zones)
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,7 +92,10 @@ export const formValuesToTTLRequest = (values: WorkspaceScheduleFormValues): Typ
}
}

export const workspaceToInitialValues = (workspace: TypesGen.Workspace): WorkspaceScheduleFormValues => {
export const workspaceToInitialValues = (
workspace: TypesGen.Workspace,
defaultTimeZone = "",
): WorkspaceScheduleFormValues => {
const schedule = workspace.autostart_schedule
const ttlHours = workspace.ttl_ms ? Math.round(workspace.ttl_ms / (1000 * 60 * 60)) : 0

Expand All@@ -106,12 +109,12 @@ export const workspaceToInitialValues = (workspace: TypesGen.Workspace): Workspa
friday: false,
saturday: false,
startTime: "",
timezone:"",
timezone:defaultTimeZone,
ttl: ttlHours,
}
}

const timezone = extractTimezone(schedule,dayjs.tz.guess())
const timezone = extractTimezone(schedule,defaultTimeZone)

const expression = cronParser.parseExpression(stripTimezone(schedule))

Expand DownExpand Up@@ -162,7 +165,7 @@ export const WorkspaceSchedulePage: React.FC = () => {
return (
<WorkspaceScheduleForm
fieldErrors={formErrors}
initialValues={workspaceToInitialValues(workspace)}
initialValues={workspaceToInitialValues(workspace, dayjs.tz.guess())}
isLoading={scheduleState.tags.has("loading")}
onCancel={() => {
navigate(`/workspaces/${workspaceId}`)
Expand Down
5 changes: 5 additions & 0 deletionssite/yarn.lock
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13270,6 +13270,11 @@ typescript@4.6.4:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9"
integrity sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==

tzdata@1.0.30:
version "1.0.30"
resolved "https://registry.yarnpkg.com/tzdata/-/tzdata-1.0.30.tgz#d9d5a4b4b5e1ed95f6255f98c0564c4256316f52"
integrity sha512-/0yogZsIRUVhGIEGZahL+Nnl9gpMD6jtQ9MlVtPVofFwhaqa+cFTgRy1desTAKqdmIJjS6CL+i6F/mnetrLaxw==

uglify-js@^3.1.4:
version "3.15.1"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.15.1.tgz#9403dc6fa5695a6172a91bc983ea39f0f7c9086d"
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp