diff --git a/site/src/pages/TemplateSettingsPage/TemplateSchedulePage/ScheduleDialog.stories.tsx b/site/src/pages/TemplateSettingsPage/TemplateSchedulePage/ScheduleDialog.stories.tsx new file mode 100644 index 0000000000000..ee29803377494 --- /dev/null +++ b/site/src/pages/TemplateSettingsPage/TemplateSchedulePage/ScheduleDialog.stories.tsx @@ -0,0 +1,33 @@ +import { action } from "@storybook/addon-actions"; +import type { Meta, StoryObj } from "@storybook/react"; +import { ScheduleDialog } from "./ScheduleDialog"; + +const meta: Meta = { + title: "pages/TemplateSettingsPage/ScheduleDialog", + component: ScheduleDialog, + args: { + onConfirm: action("onConfirm"), + onClose: action("onClose"), + open: true, + title: "Workspace Scheduling", + }, +}; + +export default meta; +type Story = StoryObj; + +export const DormancyThreshold: Story = { + args: { + dormantValueChanged: true, + inactiveWorkspacesToGoDormant: 1, + inactiveWorkspacesToGoDormantInWeek: 5, + }, +}; + +export const DormancyDeletion: Story = { + args: { + deletionValueChanged: true, + dormantWorkspacesToBeDeleted: 1, + dormantWorkspacesToBeDeletedInWeek: 5, + }, +}; diff --git a/site/src/pages/TemplateSettingsPage/TemplateSchedulePage/ScheduleDialog.tsx b/site/src/pages/TemplateSettingsPage/TemplateSchedulePage/ScheduleDialog.tsx index 357c5c7c53d8b..f5463bef1a123 100644 --- a/site/src/pages/TemplateSettingsPage/TemplateSchedulePage/ScheduleDialog.tsx +++ b/site/src/pages/TemplateSettingsPage/TemplateSchedulePage/ScheduleDialog.tsx @@ -2,7 +2,6 @@ import type { Interpolation, Theme } from "@emotion/react"; import Checkbox from "@mui/material/Checkbox"; import DialogActions from "@mui/material/DialogActions"; import FormControlLabel from "@mui/material/FormControlLabel"; -import { Stack } from "@mui/system"; import type { FC } from "react"; import type { ConfirmDialogProps } from "components/Dialogs/ConfirmDialog/ConfirmDialog"; import { Dialog, DialogActionButtons } from "components/Dialogs/Dialog"; @@ -68,11 +67,18 @@ export const ScheduleDialog: FC = ({ <>

Dormancy Threshold

- This change will result in {inactiveWorkspacesToGoDormant}{" "} - workspaces being immediately transitioned to the dormant state - and {inactiveWorkspacesToGoDormantInWeek} over the next seven - days. To prevent this, do you want to reset the inactivity - period for all template workspaces? + This change will result in{" "} + {inactiveWorkspacesToGoDormant}{" "} + {inactiveWorkspacesToGoDormant === 1 + ? "workspace" + : "workspaces"}{" "} + being immediately transitioned to the dormant state and{" "} + {inactiveWorkspacesToGoDormantInWeek}{" "} + {inactiveWorkspacesToGoDormantInWeek === 1 + ? "workspace" + : "workspaces"}{" "} + over the next 7 days. To prevent this, do you want to reset the + inactivity period for all template workspaces?

= ({ }} /> } - label="Reset" + label="Prevent Dormancy - Reset all workspace inactivity periods" /> )} @@ -92,27 +98,32 @@ export const ScheduleDialog: FC = ({ {showDeletionWarning && ( <>

Dormancy Auto-Deletion

- -

- This change will result in {dormantWorkspacesToBeDeleted}{" "} - workspaces being immediately deleted and{" "} - {dormantWorkspacesToBeDeletedInWeek} over the next 7 days. To - prevent this, do you want to reset the dormancy period for all - template workspaces? -

- { - updateDormantWorkspaces(e.target.checked); - }} - /> - } - label="Reset" - /> -
+

+ This change will result in{" "} + {dormantWorkspacesToBeDeleted}{" "} + {dormantWorkspacesToBeDeleted === 1 + ? "workspace" + : "workspaces"}{" "} + being immediately deleted and{" "} + {dormantWorkspacesToBeDeletedInWeek}{" "} + {dormantWorkspacesToBeDeletedInWeek === 1 + ? "workspace" + : "workspaces"}{" "} + over the next 7 days. To prevent this, do you want to reset the + dormancy period for all template workspaces? +

+ { + updateDormantWorkspaces(e.target.checked); + }} + /> + } + label="Prevent Deletion - Reset all workspace dormancy periods" + /> )}