1
- import { Story } from "@storybook/react" ;
1
+ import { Meta , StoryObj } from "@storybook/react" ;
2
2
import dayjs from "dayjs" ;
3
3
import advancedFormat from "dayjs/plugin/advancedFormat" ;
4
4
import timezone from "dayjs/plugin/timezone" ;
@@ -9,31 +9,19 @@ import {
9
9
} from "pages/WorkspaceSettingsPage/WorkspaceSchedulePage/schedule" ;
10
10
import { emptyTTL } from "pages/WorkspaceSettingsPage/WorkspaceSchedulePage/ttl" ;
11
11
import { mockApiError } from "testHelpers/entities" ;
12
- import {
13
- WorkspaceScheduleForm ,
14
- WorkspaceScheduleFormProps ,
15
- } from "./WorkspaceScheduleForm" ;
12
+ import { WorkspaceScheduleForm } from "./WorkspaceScheduleForm" ;
16
13
17
14
dayjs . extend ( advancedFormat ) ;
18
15
dayjs . extend ( utc ) ;
19
16
dayjs . extend ( timezone ) ;
20
17
21
- export default {
18
+ const meta : Meta < typeof WorkspaceScheduleForm > = {
22
19
title : "components/WorkspaceScheduleForm" ,
23
20
component : WorkspaceScheduleForm ,
24
- argTypes : {
25
- onCancel : {
26
- action : "onCancel" ,
27
- } ,
28
- onSubmit : {
29
- action : "onSubmit" ,
30
- } ,
31
- } ,
32
21
} ;
33
22
34
- const Template : Story < WorkspaceScheduleFormProps > = ( args ) => (
35
- < WorkspaceScheduleForm { ...args } />
36
- ) ;
23
+ export default meta ;
24
+ type Story = StoryObj < typeof WorkspaceScheduleForm > ;
37
25
38
26
const defaultInitialValues = {
39
27
autostartEnabled : true ,
@@ -42,53 +30,62 @@ const defaultInitialValues = {
42
30
ttl : 24 ,
43
31
} ;
44
32
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
+ } ,
52
41
} ,
53
42
} ;
54
43
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
+ } ,
62
52
} ,
63
53
} ;
64
54
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
+ } ,
68
59
} ;
69
60
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
+ } ,
73
65
} ;
74
66
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
+ } ,
78
71
} ;
79
72
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
+ } ,
88
84
} ;
89
85
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
+ } ,
94
91
} ;
0 commit comments