-
Notifications
You must be signed in to change notification settings - Fork 979
feat: update workspace deadline when workspace ttl updated #2165
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
Changes from 1 commit
5c443de
c2127c1
07320a4
7846dd8
6d7187d
daa9a5f
fe79c0c
85da57b
8c38a74
a4c07df
582873a
9a7c623
0278a93
a372dce
ac1d29a
23b474c
de28477
a52d815
fd86474
2b9f93c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ import { useFormik } from "formik" | |
import { FC } from "react" | ||
import * as Yup from "yup" | ||
import { FieldErrors } from "../../api/errors" | ||
import { Workspace, WorkspaceBuild } from "../../api/typesGenerated" | ||
import { Workspace } from "../../api/typesGenerated" | ||
import { getFormHelpers } from "../../util/formUtils" | ||
import { FormFooter } from "../FormFooter/FormFooter" | ||
import { FullPageForm } from "../FullPageForm/FullPageForm" | ||
|
@@ -47,8 +47,8 @@ export const Language = { | |
timezoneLabel: "Timezone", | ||
ttlLabel: "Time until shutdown (hours)", | ||
ttlHelperText: "Your workspace will automatically shut down after this amount of time has elapsed.", | ||
ttlCausesShutdownHelperText: "Your workspace will shut down ", | ||
ttlCausesShutdownAt: "at ", | ||
ttlCausesShutdownHelperText: "Your workspace will shut down", | ||
ttlCausesShutdownAt: "at", | ||
ttlCausesShutdownImmediately: "immediately!", | ||
ttlCausesShutdownSoon: "within 30 minutes.", | ||
ttlCausesNoShutdownHelperText: "Your workspace will not automatically shut down.", | ||
|
@@ -287,12 +287,13 @@ const ttlShutdownAt = (now: dayjs.Dayjs, workspace: Workspace, tz: string, newTT | |
} | ||
const newDeadline = dayjs(workspace.latest_build.updated_at).add(newTTL, "hour") | ||
if (newDeadline.isBefore(now)) { | ||
return Language.ttlCausesShutdownHelperText + Language.ttlCausesShutdownImmediately | ||
return `⚠️ ${Language.ttlCausesShutdownHelperText} ${Language.ttlCausesShutdownImmediately} ⚠️` | ||
} | ||
if (newDeadline.isBefore(now.add(30, "minute"))) { | ||
return Language.ttlCausesShutdownHelperText + Language.ttlCausesShutdownSoon | ||
return `⚠️ ${Language.ttlCausesShutdownHelperText} ${Language.ttlCausesShutdownSoon} ⚠️` | ||
} | ||
return Language.ttlCausesShutdownHelperText + Language.ttlCausesShutdownAt + newDeadline.tz(tz).format("hh:mm A z") | ||
const newDeadlineString = newDeadline.tz(tz).format("hh:mm A z") | ||
return `${Language.ttlCausesShutdownHelperText} ${Language.ttlCausesShutdownAt} ${newDeadlineString}.` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: would making the Language value a function alleviate the need for some of these keys? Example:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it would, but it would make the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No strong opinions here - that sounds good to me! |
||
} | ||
|
||
const useStyles = makeStyles({ | ||
|
Uh oh!
There was an error while loading. Please reload this page.