Skip to content

UX: Workspace Schedule Form is too top-down restricted #1958

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #1939
greyscaled opened this issue Jun 1, 2022 · 0 comments · Fixed by #2008
Closed
Tracked by #1939

UX: Workspace Schedule Form is too top-down restricted #1958

greyscaled opened this issue Jun 1, 2022 · 0 comments · Fixed by #2008
Assignees
Labels
site Area: frontend dashboard
Milestone

Comments

@greyscaled
Copy link
Contributor

User Story 👥

A real user story (thanks @ammario 🎉):

Allow setting "Days of Week" when "Start time" is unset
This one confused me. We shouldn't assume that users will fill out the form in top to bottom order.

Implementation Notes

Under the hood, the form has logic like:

disabled={form.isSubmitting || isLoading || !form.values.startTime}

At the parent level, whereby the form values are transformed into an API request, nothing should change:

export const formValuesToAutoStartRequest = (
values: WorkspaceScheduleFormValues,
): TypesGen.UpdateWorkspaceAutostartRequest => {
if (!values.startTime) {
return {
schedule: "",
}
}
const [HH, mm] = values.startTime.split(":")
// Note: Space after CRON_TZ if timezone is defined
const preparedTZ = values.timezone ? `CRON_TZ=${values.timezone} ` : ""
const makeCronString = (dow: string) => `${preparedTZ}${mm} ${HH} * * ${dow}`
const days = [
values.sunday,
values.monday,
values.tuesday,
values.wednesday,
values.thursday,
values.friday,
values.saturday,
]
const isEveryDay = days.every((day) => day)
const isMonThroughFri =
!values.sunday &&
values.monday &&
values.tuesday &&
values.wednesday &&
values.thursday &&
values.friday &&
!values.saturday &&
!values.sunday
// Handle special cases, falling through to comma-separation
if (isEveryDay) {
return {
schedule: makeCronString("*"),
}
} else if (isMonThroughFri) {
return {
schedule: makeCronString("1-5"),
}
} else {
const dow = days.reduce((previous, current, idx) => {
if (!current) {
return previous
} else {
const prefix = previous ? "," : ""
return previous + prefix + idx
}
}, "")
return {
schedule: makeCronString(dow),
}
}
}
export const formValuesToTTLRequest = (values: WorkspaceScheduleFormValues): TypesGen.UpdateWorkspaceTTLRequest => {
return {
// minutes to nanoseconds
ttl: values.ttl ? values.ttl * 60 * 60 * 1000 * 1_000_000 : undefined,
}
}

@greyscaled greyscaled added bug 🐛 site Area: frontend dashboard labels Jun 1, 2022
@greyscaled greyscaled self-assigned this Jun 2, 2022
@misskniss misskniss added this to the Community MVP milestone Jun 2, 2022
greyscaled added a commit that referenced this issue Jun 2, 2022
Resolves: #1958

Summary:

The workspace schedule form no longer disables certain fields based on
whether or not a start time is filled out. Instead, we validate that a
start time is provided if any of the days are checked.
greyscaled added a commit that referenced this issue Jun 3, 2022
Resolves: #1958

Summary:

The workspace schedule form no longer disables certain fields based on
whether or not a start time is filled out. Instead, we validate that a
start time is provided if any of the days are checked.
kylecarbs pushed a commit that referenced this issue Jun 10, 2022
Resolves: #1958

Summary:

The workspace schedule form no longer disables certain fields based on
whether or not a start time is filled out. Instead, we validate that a
start time is provided if any of the days are checked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
site Area: frontend dashboard
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants