Skip to content

feat: Add switches for auto-start and auto-stop #3358

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

Merged
merged 26 commits into from
Aug 10, 2022
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
Fix storybook
  • Loading branch information
presleyp committed Aug 10, 2022
commit af4e8e460a74a7622f66a07dc7b681c8b7dea57f
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import advancedFormat from "dayjs/plugin/advancedFormat"
import timezone from "dayjs/plugin/timezone"
import utc from "dayjs/plugin/utc"
import { defaultSchedule, emptySchedule } from "pages/WorkspaceSchedulePage/schedule"
import { emptyTTL } from "pages/WorkspaceSchedulePage/ttl"
import { defaultTTL, emptyTTL } from "pages/WorkspaceSchedulePage/ttl"
import { makeMockApiError } from "testHelpers/entities"
import { WorkspaceScheduleForm, WorkspaceScheduleFormProps } from "./WorkspaceScheduleForm"

Expand All @@ -22,51 +22,56 @@ export default {
onSubmit: {
action: "onSubmit",
},
toggleAutoStart: {
action: "toggleAutoStart",
},
toggleAutoStop: {
action: "toggleAutoStop",
},
},
}

const Template: Story<WorkspaceScheduleFormProps> = (args) => <WorkspaceScheduleForm {...args} />

const defaultInitialValues = {
autoStartEnabled: true,
...defaultSchedule(),
autoStopEnabled: true,
ttl: defaultTTL
}

export const AllDisabled = Template.bind({})
AllDisabled.args = {
autoStart: { enabled: false, schedule: emptySchedule },
autoStop: { enabled: false, ttl: emptyTTL },
initialValues: {
autoStartEnabled: false,
...emptySchedule,
autoStopEnabled: false,
ttl: emptyTTL
}
}

export const AutoStart = Template.bind({})
AutoStart.args = {
autoStart: { enabled: true, schedule: defaultSchedule() },
autoStop: { enabled: false, ttl: emptyTTL },
initialValues: {
autoStartEnabled: true,
...defaultSchedule(),
autoStopEnabled: false,
ttl: emptyTTL
},
}

export const WorkspaceWillShutdownInTwoHours = Template.bind({})
WorkspaceWillShutdownInTwoHours.args = {
autoStart: { enabled: true, schedule: defaultSchedule() },
autoStop: { enabled: true, ttl: 2 },
initialValues: { ...defaultInitialValues, ttl: 2 }
}

export const WorkspaceWillShutdownInADay = Template.bind({})
WorkspaceWillShutdownInADay.args = {
autoStart: { enabled: true, schedule: defaultSchedule() },
autoStop: { enabled: true, ttl: 24 },
initialValues: { ...defaultInitialValues, ttl: 24 }
}

export const WorkspaceWillShutdownInTwoDays = Template.bind({})
WorkspaceWillShutdownInTwoDays.args = {
autoStart: { enabled: true, schedule: defaultSchedule() },
autoStop: { enabled: true, ttl: 48 },
initialValues: { ...defaultInitialValues, ttl: 48 }
}

export const WithError = Template.bind({})
WithError.args = {
autoStart: { enabled: false, schedule: emptySchedule },
autoStop: { enabled: true, ttl: 100 },
initialValues: { ...defaultInitialValues, ttl: 100 },
initialTouched: { ttl: true },
submitScheduleError: makeMockApiError({
message: "Something went wrong.",
Expand All @@ -76,7 +81,6 @@ WithError.args = {

export const Loading = Template.bind({})
Loading.args = {
autoStart: { enabled: true, schedule: defaultSchedule() },
autoStop: { enabled: true, ttl: 2 },
initialValues: defaultInitialValues,
isLoading: true,
}