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 advancedFormat from "dayjs/plugin/advancedFormat"
|
||||||
import timezone from "dayjs/plugin/timezone"
|
import timezone from "dayjs/plugin/timezone"
|
||||||
import utc from "dayjs/plugin/utc"
|
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 { makeMockApiError } from "testHelpers/entities"
|
||||||
import {
|
import { WorkspaceScheduleForm, WorkspaceScheduleFormProps } from "./WorkspaceScheduleForm"
|
||||||
defaultWorkspaceSchedule,
|
|
||||||
WorkspaceScheduleForm,
|
|
||||||
WorkspaceScheduleFormProps,
|
|
||||||
} from "./WorkspaceScheduleForm"
|
|
||||||
|
|
||||||
dayjs.extend(advancedFormat)
|
dayjs.extend(advancedFormat)
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
@@ -24,53 +22,51 @@ export default {
|
|||||||
onSubmit: {
|
onSubmit: {
|
||||||
action: "onSubmit",
|
action: "onSubmit",
|
||||||
},
|
},
|
||||||
|
toggleAutoStart: {
|
||||||
|
action: "toggleAutoStart",
|
||||||
|
},
|
||||||
|
toggleAutoStop: {
|
||||||
|
action: "toggleAutoStop",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const Template: Story<WorkspaceScheduleFormProps> = (args) => <WorkspaceScheduleForm {...args} />
|
const Template: Story<WorkspaceScheduleFormProps> = (args) => <WorkspaceScheduleForm {...args} />
|
||||||
|
|
||||||
export const WorkspaceWillNotShutDown = Template.bind({})
|
export const AllDisabled = Template.bind({})
|
||||||
WorkspaceWillNotShutDown.args = {
|
AllDisabled.args = {
|
||||||
initialValues: {
|
autoStart: { enabled: false, schedule: emptySchedule },
|
||||||
...defaultWorkspaceSchedule(5),
|
autoStop: { enabled: false, ttl: emptyTTL },
|
||||||
ttl: 0,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WorkspaceWillShutdownInAnHour = Template.bind({})
|
export const AutoStart = Template.bind({})
|
||||||
WorkspaceWillShutdownInAnHour.args = {
|
AutoStart.args = {
|
||||||
initialValues: {
|
autoStart: { enabled: true, schedule: defaultSchedule() },
|
||||||
...defaultWorkspaceSchedule(5),
|
autoStop: { enabled: false, ttl: emptyTTL },
|
||||||
ttl: 1,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WorkspaceWillShutdownInTwoHours = Template.bind({})
|
export const WorkspaceWillShutdownInTwoHours = Template.bind({})
|
||||||
WorkspaceWillShutdownInTwoHours.args = {
|
WorkspaceWillShutdownInTwoHours.args = {
|
||||||
initialValues: {
|
autoStart: { enabled: true, schedule: defaultSchedule() },
|
||||||
...defaultWorkspaceSchedule(2),
|
autoStop: { enabled: true, ttl: 2 },
|
||||||
ttl: 2,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WorkspaceWillShutdownInADay = Template.bind({})
|
export const WorkspaceWillShutdownInADay = Template.bind({})
|
||||||
WorkspaceWillShutdownInADay.args = {
|
WorkspaceWillShutdownInADay.args = {
|
||||||
initialValues: {
|
autoStart: { enabled: true, schedule: defaultSchedule() },
|
||||||
...defaultWorkspaceSchedule(2),
|
autoStop: { enabled: true, ttl: 24 },
|
||||||
ttl: 24,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WorkspaceWillShutdownInTwoDays = Template.bind({})
|
export const WorkspaceWillShutdownInTwoDays = Template.bind({})
|
||||||
WorkspaceWillShutdownInTwoDays.args = {
|
WorkspaceWillShutdownInTwoDays.args = {
|
||||||
initialValues: {
|
autoStart: { enabled: true, schedule: defaultSchedule() },
|
||||||
...defaultWorkspaceSchedule(2),
|
autoStop: { enabled: true, ttl: 48 },
|
||||||
ttl: 48,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WithError = Template.bind({})
|
export const WithError = Template.bind({})
|
||||||
WithError.args = {
|
WithError.args = {
|
||||||
|
autoStart: { enabled: false, schedule: emptySchedule },
|
||||||
|
autoStop: { enabled: true, ttl: 100 },
|
||||||
initialTouched: { ttl: true },
|
initialTouched: { ttl: true },
|
||||||
submitScheduleError: makeMockApiError({
|
submitScheduleError: makeMockApiError({
|
||||||
message: "Something went wrong.",
|
message: "Something went wrong.",
|
||||||
@@ -79,4 +75,8 @@ WithError.args = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Loading = Template.bind({})
|
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