Skip to content

Commit 300a7df

Browse files
committed
[DDW-1142] Fixes args in passing locale to storybook
It fixes the locale in storybook to no longer be undefined.
1 parent dffbf70 commit 300a7df

File tree

15 files changed

+51
-47
lines changed

15 files changed

+51
-47
lines changed

source/renderer/app/components/loading/system-time-error/SystemTimeError.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,20 @@ class SystemTimeError extends Component<Props> {
104104
const isNTPServiceReachable = !!localTimeDifference;
105105
const allowedTimeDifferenceInSeconds = ALLOWED_TIME_DIFFERENCE / 1000000;
106106
const rawTimeOffset = (localTimeDifference || 0) / 1000;
107-
const timeOffset = humanizeDurationByLocale(rawTimeOffset, currentLocale, {
108-
delimiter: ' ',
109-
units: ['y', 'mo', 'w', 'd', 'h', 'm', 's', 'ms'],
110-
localeConfig: {
111-
'ja-JP': {
112-
spacer: '',
113-
delimiter: '',
114-
serialComma: false,
115-
},
116-
},
117-
});
107+
const timeOffset = currentLocale
108+
? humanizeDurationByLocale(rawTimeOffset, currentLocale, {
109+
delimiter: ' ',
110+
units: ['y', 'mo', 'w', 'd', 'h', 'm', 's', 'ms'],
111+
localeConfig: {
112+
'ja-JP': {
113+
spacer: '',
114+
delimiter: '',
115+
serialComma: false,
116+
},
117+
},
118+
})
119+
: null;
120+
118121
return (
119122
<div className={styles.component}>
120123
<SVGInline svg={attentionIcon} className={styles.icon} />

source/renderer/app/components/staking/delegation-center/DelegationCenterHeader.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,9 @@ class DelegationCenterHeader extends Component<Props, State> {
133133
const slot = get(networkTip, 'slot', '-');
134134
const headingFirst = intl.formatMessage(messages.headingRight);
135135
const headingSecond = intl.formatMessage(messages.headingLeft);
136-
const timeUntilFutureEpoch = humanizeDurationByLocale(
137-
this.state.timeUntilFutureEpoch,
138-
currentLocale
139-
);
136+
const timeUntilFutureEpoch = currentLocale
137+
? humanizeDurationByLocale(this.state.timeUntilFutureEpoch, currentLocale)
138+
: null;
140139
const description = intl.formatMessage(messages.description, {
141140
timeUntilFutureEpoch,
142141
});

source/renderer/app/components/wallet/settings/WalletRecoveryPhraseVerificationWidget.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ class WalletRecoveryPhraseVerificationWidget extends Component<Props> {
196196
times.warning,
197197
'days'
198198
);
199-
let timeUntilWarning = moment()
200-
.locale(locale)
201-
.to(timeFromCreationToWarning, true);
199+
let timeUntilWarning = locale
200+
? moment().locale(locale).to(timeFromCreationToWarning, true)
201+
: null;
202202

203203
// The content is generated by `moment`, but we need to replace `ヶ月` by `か月`
204204
if (locale === LOCALES.japanese) {

storybook/stories/common/Widgets.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ storiesOf('Common / Widgets', module)
147147
</div>
148148
))
149149
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '(props: { locale: string;}) =... Remove this comment to see the full error message
150-
.add('BigButtonForDialogs', (props: { locale: string }) => (
150+
.add('BigButtonForDialogs', (_, props: { locale: string }) => (
151151
<div>
152152
<div
153153
style={{
@@ -202,11 +202,11 @@ storiesOf('Common / Widgets', module)
202202
))
203203
.add('TinySwitch', () => <TinySwitch />)
204204
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '(props: { locale: string;}) =... Remove this comment to see the full error message
205-
.add('TinySwitch - short label', (props: { locale: string }) => (
205+
.add('TinySwitch - short label', (_, props: { locale: string }) => (
206206
<TinySwitch label={intl[props.locale].formatMessage(messages.save)} />
207207
))
208208
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '(props: { locale: string;}) =... Remove this comment to see the full error message
209-
.add('ButtonLink', (props: { locale: string }) => (
209+
.add('ButtonLink', (_, props: { locale: string }) => (
210210
<ButtonLink
211211
label={intl[props.locale].formatMessage(messages.save)}
212212
// @ts-ignore ts-migrate(2769) FIXME: No overload matches this call.

storybook/stories/navigation/Sidebar.stories.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ storiesOf('Navigation / Sidebar', module)
113113
))
114114
.addDecorator(withKnobs) // ====== Stories ======
115115
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '(props: { currentTheme: strin... Remove this comment to see the full error message
116-
.add('No Category', (props: { currentTheme: string }) => (
116+
.add('No Category', (_, props: { currentTheme: string }) => (
117117
<Sidebar
118118
menus={emptyMenus}
119119
categories={CATEGORIES_WITH_DELEGATION_COUNTDOWN}
@@ -131,7 +131,7 @@ storiesOf('Navigation / Sidebar', module)
131131
/>
132132
))
133133
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '(props: { currentTheme: strin... Remove this comment to see the full error message
134-
.add('Wallets Category', (props: { currentTheme: string }) => (
134+
.add('Wallets Category', (_, props: { currentTheme: string }) => (
135135
<Sidebar
136136
menus={emptyMenus}
137137
categories={CATEGORIES_WITH_DELEGATION_COUNTDOWN}
@@ -149,7 +149,7 @@ storiesOf('Navigation / Sidebar', module)
149149
/>
150150
))
151151
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '(props: { currentTheme: strin... Remove this comment to see the full error message
152-
.add('Wallet Selected', (props: { currentTheme: string }) => (
152+
.add('Wallet Selected', (_, props: { currentTheme: string }) => (
153153
<Sidebar
154154
categories={CATEGORIES_WITH_DELEGATION_COUNTDOWN}
155155
activeSidebarCategory={CATEGORIES_WITH_DELEGATION_COUNTDOWN[0].route}
@@ -169,7 +169,7 @@ storiesOf('Navigation / Sidebar', module)
169169
/>
170170
))
171171
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '(props: { currentTheme: strin... Remove this comment to see the full error message
172-
.add('Hardware Wallet Selected', (props: { currentTheme: string }) => (
172+
.add('Hardware Wallet Selected', (_, props: { currentTheme: string }) => (
173173
<Sidebar
174174
categories={CATEGORIES_WITH_DELEGATION_COUNTDOWN}
175175
activeSidebarCategory={CATEGORIES_WITH_DELEGATION_COUNTDOWN[1].route}
@@ -188,7 +188,7 @@ storiesOf('Navigation / Sidebar', module)
188188
/>
189189
))
190190
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '(props: { currentTheme: strin... Remove this comment to see the full error message
191-
.add('Delegation Category', (props: { currentTheme: string }) => (
191+
.add('Delegation Category', (_, props: { currentTheme: string }) => (
192192
<Sidebar
193193
menus={emptyMenus}
194194
categories={CATEGORIES_WITH_DELEGATION_COUNTDOWN}
@@ -208,7 +208,7 @@ storiesOf('Navigation / Sidebar', module)
208208
.add(
209209
'Decentralization Progress Category',
210210
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '(props: { currentTheme: strin... Remove this comment to see the full error message
211-
(props: { currentTheme: string }) => (
211+
(_, props: { currentTheme: string }) => (
212212
<Sidebar
213213
menus={emptyMenus}
214214
categories={CATEGORIES_WITHOUT_DELEGATION_COUNTDOWN}
@@ -227,7 +227,7 @@ storiesOf('Navigation / Sidebar', module)
227227
)
228228
)
229229
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '(props: { currentTheme: strin... Remove this comment to see the full error message
230-
.add('Network label', (props: { currentTheme: string }) => (
230+
.add('Network label', (_, props: { currentTheme: string }) => (
231231
<Sidebar
232232
menus={emptyMenus}
233233
categories={CATEGORIES_WITH_DELEGATION_COUNTDOWN}

storybook/stories/news/AlertsOverlay.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ storiesOf('News / Overlays', module)
9292
<StoryDecorator>{withKnobs(story, context)}</StoryDecorator>
9393
))
9494
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '(props: { locale: string;}) =... Remove this comment to see the full error message
95-
.add('Alerts', (props: { locale: string }) => (
95+
.add('Alerts', (_, props: { locale: string }) => (
9696
<AlertsOverlay
9797
allAlertsCount={getAlerts(props.locale).length}
9898
alerts={getAlerts(props.locale)}

storybook/stories/news/AppUpdateOverlay.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ storiesOf('News / Overlays', module)
1111
.addDecorator((story) => <StoryDecorator>{story()}</StoryDecorator>)
1212
.addDecorator(withKnobs)
1313
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '({ locale }: { locale: string; }... Remove this comment to see the full error message
14-
.add('Update', ({ locale }: { locale: string }) => {
14+
.add('Update', (_, { locale }: { locale: string }) => {
1515
const scenario = radios(
1616
'Scenario',
1717
{

storybook/stories/news/NewsFeed.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ storiesOf('News / NewsFeed', module)
6262
</div>
6363
))
6464
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '({ locale }: { locale: string; }... Remove this comment to see the full error message
65-
.add('Fetched', ({ locale }: { locale: string }) => {
65+
.add('Fetched', (_, { locale }: { locale: string }) => {
6666
const displayAppUpdateNewsItem = boolean('displayAppUpdateNewsItem', true);
6767
const updateDownloadProgress = displayAppUpdateNewsItem
6868
? number('updateDownloadProgress', 30, updateDownloadProgressOptions)

storybook/stories/nodes/errors/Errors.stories.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ storiesOf('Nodes / Errors', module)
1212
)) // ====== Stories ======
1313
.add('No Disk Space Error', NoDiskSpaceErrorStory)
1414
// @ts-ignore ts-migrate(2345) FIXME: Argument of type '({ locale }: { locale: string; }... Remove this comment to see the full error message
15-
.add('System Time Error', SystemTimeErrorStory);
15+
.add('System Time Error', (_, props) => (
16+
<SystemTimeErrorStory locale={props.locale} />
17+
));

storybook/stories/settings/general/General.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ storiesOf('Settings / General', module)
113113
}}
114114
/>
115115
))
116-
.add('Terms of Service', (props) => {
116+
.add('Terms of Service', (_, props) => {
117117
const termsOfUseSource = require(`../../../../source/renderer/app/i18n/locales/terms-of-use/${props.locale}.md`);
118118

119119
return (

0 commit comments

Comments
 (0)