Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
make it prettier
  • Loading branch information
johnstcn committed Jun 8, 2022
commit fe79c0c6e098dc057b8050079e36609708638d18
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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}.`
Copy link
Member

Choose a reason for hiding this comment

The 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:

const Language = {
  ttlCausesShutdownAtText: (newDeadlineString: string): string => {
    return `Your workspace will shut down at ${newDeadlineString}`
  },
}

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 guess it would, but it would make the Language portion more complex. I feel like we'd want to keep Language as a simple lookup table and keep the complexity close to where it's used. I'm fine with going either way though if folks have strong opinions about it!

Copy link
Member

Choose a reason for hiding this comment

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

No strong opinions here - that sounds good to me!

}

const useStyles = makeStyles({
Expand Down