Skip to content

Commit de276ee

Browse files
committed
Refactor WorkspaceSettingsPage stories
1 parent 275bfd4 commit de276ee

File tree

3 files changed

+64
-80
lines changed

3 files changed

+64
-80
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import { ComponentMeta, Story } from "@storybook/react";
2-
import {
3-
WorkspaceParametersPageView,
4-
WorkspaceParametersPageViewProps,
5-
} from "./WorkspaceParametersPage";
6-
import { action } from "@storybook/addon-actions";
1+
import { Meta, StoryObj } from "@storybook/react";
2+
import { WorkspaceParametersPageView } from "./WorkspaceParametersPage";
73
import {
84
MockWorkspaceBuildParameter1,
95
MockWorkspaceBuildParameter2,
@@ -13,13 +9,13 @@ import {
139
MockWorkspaceBuildParameter3,
1410
} from "testHelpers/entities";
1511

16-
export default {
12+
const meta: Meta<typeof WorkspaceParametersPageView> = {
1713
title: "pages/WorkspaceParametersPageView",
1814
component: WorkspaceParametersPageView,
1915
args: {
2016
submitError: undefined,
2117
isSubmitting: false,
22-
onCancel: action("cancel"),
18+
2319
data: {
2420
buildParameters: [
2521
MockWorkspaceBuildParameter1,
@@ -36,11 +32,9 @@ export default {
3632
],
3733
},
3834
},
39-
} as ComponentMeta<typeof WorkspaceParametersPageView>;
35+
};
4036

41-
const Template: Story<WorkspaceParametersPageViewProps> = (args) => (
42-
<WorkspaceParametersPageView {...args} />
43-
);
37+
export default meta;
38+
type Story = StoryObj<typeof WorkspaceParametersPageView>;
4439

45-
export const Example = Template.bind({});
46-
Example.args = {};
40+
export const Example: Story = {};
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Story } from "@storybook/react";
1+
import { Meta, StoryObj } from "@storybook/react";
22
import dayjs from "dayjs";
33
import advancedFormat from "dayjs/plugin/advancedFormat";
44
import timezone from "dayjs/plugin/timezone";
@@ -9,31 +9,19 @@ import {
99
} from "pages/WorkspaceSettingsPage/WorkspaceSchedulePage/schedule";
1010
import { emptyTTL } from "pages/WorkspaceSettingsPage/WorkspaceSchedulePage/ttl";
1111
import { mockApiError } from "testHelpers/entities";
12-
import {
13-
WorkspaceScheduleForm,
14-
WorkspaceScheduleFormProps,
15-
} from "./WorkspaceScheduleForm";
12+
import { WorkspaceScheduleForm } from "./WorkspaceScheduleForm";
1613

1714
dayjs.extend(advancedFormat);
1815
dayjs.extend(utc);
1916
dayjs.extend(timezone);
2017

21-
export default {
18+
const meta: Meta<typeof WorkspaceScheduleForm> = {
2219
title: "components/WorkspaceScheduleForm",
2320
component: WorkspaceScheduleForm,
24-
argTypes: {
25-
onCancel: {
26-
action: "onCancel",
27-
},
28-
onSubmit: {
29-
action: "onSubmit",
30-
},
31-
},
3221
};
3322

34-
const Template: Story<WorkspaceScheduleFormProps> = (args) => (
35-
<WorkspaceScheduleForm {...args} />
36-
);
23+
export default meta;
24+
type Story = StoryObj<typeof WorkspaceScheduleForm>;
3725

3826
const defaultInitialValues = {
3927
autostartEnabled: true,
@@ -42,53 +30,62 @@ const defaultInitialValues = {
4230
ttl: 24,
4331
};
4432

45-
export const AllDisabled = Template.bind({});
46-
AllDisabled.args = {
47-
initialValues: {
48-
autostartEnabled: false,
49-
...emptySchedule,
50-
autostopEnabled: false,
51-
ttl: emptyTTL,
33+
export const AllDisabled: Story = {
34+
args: {
35+
initialValues: {
36+
autostartEnabled: false,
37+
...emptySchedule,
38+
autostopEnabled: false,
39+
ttl: emptyTTL,
40+
},
5241
},
5342
};
5443

55-
export const Autostart = Template.bind({});
56-
Autostart.args = {
57-
initialValues: {
58-
autostartEnabled: true,
59-
...defaultSchedule(),
60-
autostopEnabled: false,
61-
ttl: emptyTTL,
44+
export const Autostart: Story = {
45+
args: {
46+
initialValues: {
47+
autostartEnabled: true,
48+
...defaultSchedule(),
49+
autostopEnabled: false,
50+
ttl: emptyTTL,
51+
},
6252
},
6353
};
6454

65-
export const WorkspaceWillShutdownInTwoHours = Template.bind({});
66-
WorkspaceWillShutdownInTwoHours.args = {
67-
initialValues: { ...defaultInitialValues, ttl: 2 },
55+
export const WorkspaceWillShutdownInTwoHours: Story = {
56+
args: {
57+
initialValues: { ...defaultInitialValues, ttl: 2 },
58+
},
6859
};
6960

70-
export const WorkspaceWillShutdownInADay = Template.bind({});
71-
WorkspaceWillShutdownInADay.args = {
72-
initialValues: { ...defaultInitialValues, ttl: 24 },
61+
export const WorkspaceWillShutdownInADay: Story = {
62+
args: {
63+
initialValues: { ...defaultInitialValues, ttl: 24 },
64+
},
7365
};
7466

75-
export const WorkspaceWillShutdownInTwoDays = Template.bind({});
76-
WorkspaceWillShutdownInTwoDays.args = {
77-
initialValues: { ...defaultInitialValues, ttl: 48 },
67+
export const WorkspaceWillShutdownInTwoDays: Story = {
68+
args: {
69+
initialValues: { ...defaultInitialValues, ttl: 48 },
70+
},
7871
};
7972

80-
export const WithError = Template.bind({});
81-
WithError.args = {
82-
initialValues: { ...defaultInitialValues, ttl: 100 },
83-
initialTouched: { ttl: true },
84-
submitScheduleError: mockApiError({
85-
message: "Something went wrong.",
86-
validations: [{ field: "ttl_ms", detail: "Invalid time until shutdown." }],
87-
}),
73+
export const WithError: Story = {
74+
args: {
75+
initialValues: { ...defaultInitialValues, ttl: 100 },
76+
initialTouched: { ttl: true },
77+
submitScheduleError: mockApiError({
78+
message: "Something went wrong.",
79+
validations: [
80+
{ field: "ttl_ms", detail: "Invalid time until shutdown." },
81+
],
82+
}),
83+
},
8884
};
8985

90-
export const Loading = Template.bind({});
91-
Loading.args = {
92-
initialValues: defaultInitialValues,
93-
isLoading: true,
86+
export const Loading: Story = {
87+
args: {
88+
initialValues: defaultInitialValues,
89+
isLoading: true,
90+
},
9491
};
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
1-
import { ComponentMeta, Story } from "@storybook/react";
1+
import { Meta, StoryObj } from "@storybook/react";
22
import { MockWorkspace } from "testHelpers/entities";
3-
import {
4-
WorkspaceSettingsPageView,
5-
WorkspaceSettingsPageViewProps,
6-
} from "./WorkspaceSettingsPageView";
7-
import { action } from "@storybook/addon-actions";
3+
import { WorkspaceSettingsPageView } from "./WorkspaceSettingsPageView";
84

9-
export default {
5+
const meta: Meta<typeof WorkspaceSettingsPageView> = {
106
title: "pages/WorkspaceSettingsPageView",
117
component: WorkspaceSettingsPageView,
128
args: {
139
error: undefined,
1410
isSubmitting: false,
1511
workspace: MockWorkspace,
16-
onCancel: action("cancel"),
1712
},
18-
} as ComponentMeta<typeof WorkspaceSettingsPageView>;
13+
};
1914

20-
const Template: Story<WorkspaceSettingsPageViewProps> = (args) => (
21-
<WorkspaceSettingsPageView {...args} />
22-
);
15+
export default meta;
16+
type Story = StoryObj<typeof WorkspaceSettingsPageView>;
2317

24-
export const Example = Template.bind({});
25-
Example.args = {};
18+
export const Example: Story = {};

0 commit comments

Comments
 (0)