Skip to content

feat: add user quiet hours settings page #9525

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
wants to merge 6 commits into from

Conversation

deansheather
Copy link
Member

@deansheather deansheather commented Sep 5, 2023

Adds a new user settings page if the deployment has the template_autostop_requirement feature enabled.

The new user settings page shows the current daily quiet hours schedule time and the timezone, as well as the next scheduled time and the raw cron expression.

Quiet hours allows users to pick when their workspaces will be auto turned off due to template requirements. Templates can specify "restart every saturday" for example, and the user picks which time of the day that will happen in their own timezone.

Closes #9285

@aslilac aslilac self-requested a review September 6, 2023 20:55
Copy link
Member

@aslilac aslilac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the new ScheduleForm.stories.tsx file, it looks like you used the older-style story format that we're currently migrating away from. There's a good simple example or the new format in Alert.stories.tsx.

Did you have anything specific you wanted UI feedback on? and could you please elaborate a bit about what this feature does in the PR description?

}

// Taken from https://stackoverflow.com/a/54500197
const allTimezonesFallback = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels like this might be worth putting in a more generic file

Comment on lines +586 to +609
const formatNextRun = (
hours: number,
minutes: number,
tz: string,
now: Date | undefined,
): string => {
const nowDjs = dayjs(now).tz(tz)
const djs = dayjs(evaluateNextRun(hours, minutes, tz, now)).tz(tz)
let str = djs.format("h:mm A")
if (djs.isSame(nowDjs, "day")) {
str += " today"
} else if (djs.isSame(nowDjs.add(1, "day"), "day")) {
str += " tomorrow"
} else {
// This case will rarely ever be hit, as we're dealing with only times and
// not dates, but it can be hit due to mismatched browser timezone to cron
// timezone or due to daylight savings changes.
str += ` on ${djs.format("dddd, MMMM D")}`
}

str += ` (${djs.from(now)})`

return str
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels like the kind of thing that dayjs should just support. does it not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you can do complex formatting like this. This is h:mm A [today|tomorrow|on dddd, MMMM D] (in 12 hours)

@aslilac
Copy link
Member

aslilac commented Sep 14, 2023

Closing in favor of #9676

@aslilac aslilac closed this Sep 14, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 14, 2023
@github-actions github-actions bot deleted the dean/user-quiet-hours-page branch March 7, 2024 00:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

quiet hours: provide a UI for users to set hours
2 participants