Skip to content

Commit 01259db

Browse files
committed
Refactor WorkspaceStatusBadge stories
1 parent 88666c6 commit 01259db

File tree

1 file changed

+63
-52
lines changed

1 file changed

+63
-52
lines changed
Lines changed: 63 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Story } from "@storybook/react";
21
import {
32
MockCanceledWorkspace,
43
MockCancelingWorkspace,
@@ -15,16 +14,9 @@ import {
1514
MockExperiments,
1615
MockAppearance,
1716
} from "testHelpers/entities";
18-
import {
19-
WorkspaceStatusBadge,
20-
WorkspaceStatusBadgeProps,
21-
} from "./WorkspaceStatusBadge";
17+
import { WorkspaceStatusBadge } from "./WorkspaceStatusBadge";
2218
import { DashboardProviderContext } from "components/Dashboard/DashboardProvider";
23-
24-
export default {
25-
title: "components/WorkspaceStatusBadge",
26-
component: WorkspaceStatusBadge,
27-
};
19+
import type { Meta, StoryObj } from "@storybook/react";
2820

2921
const MockedAppearance = {
3022
config: MockAppearance,
@@ -33,65 +25,84 @@ const MockedAppearance = {
3325
save: () => null,
3426
};
3527

36-
const Template: Story<WorkspaceStatusBadgeProps> = (args) => (
37-
<DashboardProviderContext.Provider
38-
value={{
39-
buildInfo: MockBuildInfo,
40-
entitlements: MockEntitlementsWithScheduling,
41-
experiments: MockExperiments,
42-
appearance: MockedAppearance,
43-
}}
44-
>
45-
<WorkspaceStatusBadge {...args} />
46-
</DashboardProviderContext.Provider>
47-
);
28+
const meta: Meta<typeof WorkspaceStatusBadge> = {
29+
title: "components/WorkspaceStatusBadge",
30+
component: WorkspaceStatusBadge,
31+
decorators: [
32+
(Story) => (
33+
<DashboardProviderContext.Provider
34+
value={{
35+
buildInfo: MockBuildInfo,
36+
entitlements: MockEntitlementsWithScheduling,
37+
experiments: MockExperiments,
38+
appearance: MockedAppearance,
39+
}}
40+
>
41+
<Story />
42+
</DashboardProviderContext.Provider>
43+
),
44+
],
45+
};
46+
47+
export default meta;
48+
type Story = StoryObj<typeof WorkspaceStatusBadge>;
4849

49-
export const Running = Template.bind({});
50-
Running.args = {
51-
workspace: MockWorkspace,
50+
export const Running: Story = {
51+
args: {
52+
workspace: MockWorkspace,
53+
},
5254
};
5355

54-
export const Starting = Template.bind({});
55-
Starting.args = {
56-
workspace: MockStartingWorkspace,
56+
export const Starting: Story = {
57+
args: {
58+
workspace: MockStartingWorkspace,
59+
},
5760
};
5861

59-
export const Stopped = Template.bind({});
60-
Stopped.args = {
61-
workspace: MockStoppedWorkspace,
62+
export const Stopped: Story = {
63+
args: {
64+
workspace: MockStoppedWorkspace,
65+
},
6266
};
6367

64-
export const Stopping = Template.bind({});
65-
Stopping.args = {
66-
workspace: MockStoppingWorkspace,
68+
export const Stopping: Story = {
69+
args: {
70+
workspace: MockStoppingWorkspace,
71+
},
6772
};
6873

69-
export const Deleting = Template.bind({});
70-
Deleting.args = {
71-
workspace: MockDeletingWorkspace,
74+
export const Deleting: Story = {
75+
args: {
76+
workspace: MockDeletingWorkspace,
77+
},
7278
};
7379

74-
export const Deleted = Template.bind({});
75-
Deleted.args = {
76-
workspace: MockDeletedWorkspace,
80+
export const Deleted: Story = {
81+
args: {
82+
workspace: MockDeletedWorkspace,
83+
},
7784
};
7885

79-
export const Canceling = Template.bind({});
80-
Canceling.args = {
81-
workspace: MockCancelingWorkspace,
86+
export const Canceling: Story = {
87+
args: {
88+
workspace: MockCancelingWorkspace,
89+
},
8290
};
8391

84-
export const Canceled = Template.bind({});
85-
Canceled.args = {
86-
workspace: MockCanceledWorkspace,
92+
export const Canceled: Story = {
93+
args: {
94+
workspace: MockCanceledWorkspace,
95+
},
8796
};
8897

89-
export const Failed = Template.bind({});
90-
Failed.args = {
91-
workspace: MockFailedWorkspace,
98+
export const Failed: Story = {
99+
args: {
100+
workspace: MockFailedWorkspace,
101+
},
92102
};
93103

94-
export const Pending = Template.bind({});
95-
Pending.args = {
96-
workspace: MockPendingWorkspace,
104+
export const Pending: Story = {
105+
args: {
106+
workspace: MockPendingWorkspace,
107+
},
97108
};

0 commit comments

Comments
 (0)