-
Notifications
You must be signed in to change notification settings - Fork 887
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
Conversation
There was a problem hiding this 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 = [ |
There was a problem hiding this comment.
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
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 | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
Closing in favor of #9676 |
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