Skip to content

Commit 5ef249b

Browse files
authored
Merge branch 'develop' into chore/ddw-1167-increase-min-free-space-to-4gb
2 parents ccc9ddf + dd5bb20 commit 5ef249b

File tree

2 files changed

+71
-29
lines changed

2 files changed

+71
-29
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Chores
66

77
- Increase minimum free space required from 2gb to 4gb ([PR 3071](https://github.com/input-output-hk/daedalus/pull/3071))
8+
- Fixed Language components in Storybook to have it's own mocked store ([PR 3063](https://github.com/input-output-hk/daedalus/pull/3063))
89
- Updated `cardano-node` configs for Preprod respin ([PR 3070](https://github.com/input-output-hk/daedalus/pull/3070))
910
- Fixed the properties and providers for the Send stories ([PR 3047](https://github.com/input-output-hk/daedalus/pull/3047))
1011
- Fixed locale in Storybook ([PR 3062](https://github.com/input-output-hk/daedalus/pull/3062))
Lines changed: 70 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,81 @@
11
import React from 'react';
22
import { storiesOf } from '@storybook/react';
33
import { action } from '@storybook/addon-actions';
4-
import StoryDecorator from '../../_support/StoryDecorator';
5-
import InitialSettings from '../../../../source/renderer/app/components/profile/initial-settings/InitialSettings';
4+
import { withState, Store } from '@dump247/storybook-state';
65
import {
76
DATE_ENGLISH_OPTIONS,
7+
LANGUAGE_OPTIONS,
88
NUMBER_OPTIONS,
99
TIME_OPTIONS,
1010
} from '../../../../source/renderer/app/config/profileConfig';
11+
import StoryDecorator from '../../_support/StoryDecorator';
12+
import InitialSettings from '../../../../source/renderer/app/components/profile/initial-settings/InitialSettings';
13+
14+
interface StoryStore {
15+
currentDateFormat: string;
16+
currentNumberFormat: string;
17+
currentTimeFormat: string;
18+
currentLocale: string;
19+
}
20+
21+
const mockedLanguageState = {
22+
currentDateFormat: DATE_ENGLISH_OPTIONS[0].value,
23+
currentNumberFormat: NUMBER_OPTIONS[0].value,
24+
currentTimeFormat: TIME_OPTIONS[0].value,
25+
currentLocale: LANGUAGE_OPTIONS[0].value,
26+
};
27+
28+
const onValueChange = (
29+
store: Store<StoryStore>,
30+
id: string,
31+
value: string
32+
): void => {
33+
const fieldIdToStoreKeyMap = {
34+
dateFormat: 'currentDateFormat',
35+
numberFormat: 'currentNumberFormat',
36+
timeFormat: 'currentTimeFormat',
37+
locale: 'currentLocale',
38+
};
39+
40+
store.set({
41+
[fieldIdToStoreKeyMap[id]]: value,
42+
});
43+
44+
if (id === 'locale') {
45+
const currentDateFormat =
46+
value === mockedLanguageState.currentLocale
47+
? mockedLanguageState.currentDateFormat
48+
: 'YYYY年MM月DD日';
49+
store.set({
50+
currentDateFormat,
51+
});
52+
}
53+
};
1154

1255
storiesOf('Settings / Language', module)
1356
.addDecorator((story) => <StoryDecorator>{story()}</StoryDecorator>) // ====== Stories ======
14-
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '({ locale }: { locale: string; }... Remove this comment to see the full error message
15-
.add('Select Language - initial', (_, { locale }: { locale: string }) => (
16-
<div>
17-
<InitialSettings
18-
onSubmit={action('submit')}
19-
onChangeItem={action('onChangeItem')}
20-
currentDateFormat={DATE_ENGLISH_OPTIONS[0].value}
21-
currentLocale={locale}
22-
currentNumberFormat={NUMBER_OPTIONS[0].value}
23-
currentTimeFormat={TIME_OPTIONS[0].value}
24-
/>
25-
</div>
26-
))
27-
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '({ locale }: { locale: string; }... Remove this comment to see the full error message
28-
.add('Select Language - submitting', (_, { locale }: { locale: string }) => (
29-
<div>
30-
<InitialSettings
31-
onSubmit={action('submit')}
32-
onChangeItem={action('onChangeItem')}
33-
currentDateFormat={DATE_ENGLISH_OPTIONS[0].value}
34-
currentLocale={locale}
35-
currentNumberFormat={NUMBER_OPTIONS[0].value}
36-
currentTimeFormat={TIME_OPTIONS[0].value}
37-
isSubmitting
38-
/>
39-
</div>
40-
));
57+
.add(
58+
'Select Language - initial',
59+
withState(mockedLanguageState, (store) => (
60+
<div>
61+
<InitialSettings
62+
onSubmit={action('submit')}
63+
onChangeItem={(id, value) => onValueChange(store, id, value)}
64+
{...store.state}
65+
/>
66+
</div>
67+
))
68+
)
69+
.add(
70+
'Select Language - submitting',
71+
withState(mockedLanguageState, (store) => (
72+
<div>
73+
<InitialSettings
74+
onSubmit={action('submit')}
75+
onChangeItem={(id, value) => onValueChange(store, id, value)}
76+
isSubmitting
77+
{...store.state}
78+
/>
79+
</div>
80+
))
81+
);

0 commit comments

Comments
 (0)