mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
Update storybook
This commit is contained in:
@@ -3,12 +3,10 @@ import dayjs from "dayjs"
|
||||
import advancedFormat from "dayjs/plugin/advancedFormat"
|
||||
import timezone from "dayjs/plugin/timezone"
|
||||
import utc from "dayjs/plugin/utc"
|
||||
import { defaultSchedule, emptySchedule } from "pages/WorkspacesPage/schedule"
|
||||
import { emptyTTL } from "pages/WorkspacesPage/ttl"
|
||||
import { makeMockApiError } from "testHelpers/entities"
|
||||
import {
|
||||
defaultWorkspaceSchedule,
|
||||
WorkspaceScheduleForm,
|
||||
WorkspaceScheduleFormProps,
|
||||
} from "./WorkspaceScheduleForm"
|
||||
import { WorkspaceScheduleForm, WorkspaceScheduleFormProps } from "./WorkspaceScheduleForm"
|
||||
|
||||
dayjs.extend(advancedFormat)
|
||||
dayjs.extend(utc)
|
||||
@@ -24,53 +22,51 @@ export default {
|
||||
onSubmit: {
|
||||
action: "onSubmit",
|
||||
},
|
||||
toggleAutoStart: {
|
||||
action: "toggleAutoStart",
|
||||
},
|
||||
toggleAutoStop: {
|
||||
action: "toggleAutoStop",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const Template: Story<WorkspaceScheduleFormProps> = (args) => <WorkspaceScheduleForm {...args} />
|
||||
|
||||
export const WorkspaceWillNotShutDown = Template.bind({})
|
||||
WorkspaceWillNotShutDown.args = {
|
||||
initialValues: {
|
||||
...defaultWorkspaceSchedule(5),
|
||||
ttl: 0,
|
||||
},
|
||||
export const AllDisabled = Template.bind({})
|
||||
AllDisabled.args = {
|
||||
autoStart: { enabled: false, schedule: emptySchedule },
|
||||
autoStop: { enabled: false, ttl: emptyTTL },
|
||||
}
|
||||
|
||||
export const WorkspaceWillShutdownInAnHour = Template.bind({})
|
||||
WorkspaceWillShutdownInAnHour.args = {
|
||||
initialValues: {
|
||||
...defaultWorkspaceSchedule(5),
|
||||
ttl: 1,
|
||||
},
|
||||
export const AutoStart = Template.bind({})
|
||||
AutoStart.args = {
|
||||
autoStart: { enabled: true, schedule: defaultSchedule() },
|
||||
autoStop: { enabled: false, ttl: emptyTTL },
|
||||
}
|
||||
|
||||
export const WorkspaceWillShutdownInTwoHours = Template.bind({})
|
||||
WorkspaceWillShutdownInTwoHours.args = {
|
||||
initialValues: {
|
||||
...defaultWorkspaceSchedule(2),
|
||||
ttl: 2,
|
||||
},
|
||||
autoStart: { enabled: true, schedule: defaultSchedule() },
|
||||
autoStop: { enabled: true, ttl: 2 },
|
||||
}
|
||||
|
||||
export const WorkspaceWillShutdownInADay = Template.bind({})
|
||||
WorkspaceWillShutdownInADay.args = {
|
||||
initialValues: {
|
||||
...defaultWorkspaceSchedule(2),
|
||||
ttl: 24,
|
||||
},
|
||||
autoStart: { enabled: true, schedule: defaultSchedule() },
|
||||
autoStop: { enabled: true, ttl: 24 },
|
||||
}
|
||||
|
||||
export const WorkspaceWillShutdownInTwoDays = Template.bind({})
|
||||
WorkspaceWillShutdownInTwoDays.args = {
|
||||
initialValues: {
|
||||
...defaultWorkspaceSchedule(2),
|
||||
ttl: 48,
|
||||
},
|
||||
autoStart: { enabled: true, schedule: defaultSchedule() },
|
||||
autoStop: { enabled: true, ttl: 48 },
|
||||
}
|
||||
|
||||
export const WithError = Template.bind({})
|
||||
WithError.args = {
|
||||
autoStart: { enabled: false, schedule: emptySchedule },
|
||||
autoStop: { enabled: true, ttl: 100 },
|
||||
initialTouched: { ttl: true },
|
||||
submitScheduleError: makeMockApiError({
|
||||
message: "Something went wrong.",
|
||||
@@ -79,4 +75,8 @@ WithError.args = {
|
||||
}
|
||||
|
||||
export const Loading = Template.bind({})
|
||||
Loading.args = { isLoading: true }
|
||||
Loading.args = {
|
||||
autoStart: { enabled: true, schedule: defaultSchedule() },
|
||||
autoStop: { enabled: true, ttl: 2 },
|
||||
isLoading: true,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user