2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-02-12 21:30:58 +00:00
|
|
|
import * as React from 'react';
|
2020-09-12 00:46:52 +00:00
|
|
|
import { storiesOf } from '@storybook/react';
|
|
|
|
import { boolean, select } from '@storybook/addon-knobs';
|
|
|
|
import { action } from '@storybook/addon-actions';
|
2020-02-12 21:30:58 +00:00
|
|
|
import { UpdateDialog } from './UpdateDialog';
|
|
|
|
|
|
|
|
import { setup as setupI18n } from '../../js/modules/i18n';
|
|
|
|
import enMessages from '../../_locales/en/messages.json';
|
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
ackRender: action('ack-render'),
|
|
|
|
dismissDialog: action('dismiss-dialog'),
|
|
|
|
hasNetworkDialog: false,
|
|
|
|
i18n,
|
2020-02-21 00:09:50 +00:00
|
|
|
didSnooze: false,
|
|
|
|
showEventsCount: 0,
|
|
|
|
snoozeUpdate: action('snooze-update'),
|
2020-02-12 21:30:58 +00:00
|
|
|
startUpdate: action('start-update'),
|
|
|
|
};
|
|
|
|
|
|
|
|
const permutations = [
|
|
|
|
{
|
|
|
|
title: 'Update',
|
|
|
|
props: {
|
|
|
|
dialogType: 1,
|
|
|
|
},
|
|
|
|
},
|
2020-02-21 00:09:50 +00:00
|
|
|
{
|
|
|
|
title: 'Update (didSnooze=true)',
|
|
|
|
props: {
|
|
|
|
dialogType: 1,
|
|
|
|
didSnooze: true,
|
|
|
|
},
|
|
|
|
},
|
2020-02-12 21:30:58 +00:00
|
|
|
{
|
|
|
|
title: 'Cannot Update',
|
|
|
|
props: {
|
|
|
|
dialogType: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'MacOS Read Only Error',
|
|
|
|
props: {
|
|
|
|
dialogType: 3,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
storiesOf('Components/UpdateDialog', module)
|
|
|
|
.add('Knobs Playground', () => {
|
|
|
|
const dialogType = select(
|
|
|
|
'dialogType',
|
|
|
|
{
|
|
|
|
None: 0,
|
|
|
|
Update: 1,
|
|
|
|
Cannot_Update: 2,
|
|
|
|
MacOS_Read_Only: 3,
|
|
|
|
},
|
|
|
|
1
|
|
|
|
);
|
|
|
|
const hasNetworkDialog = boolean('hasNetworkDialog', false);
|
2020-02-21 00:09:50 +00:00
|
|
|
const didSnooze = boolean('didSnooze', false);
|
2020-02-12 21:30:58 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<UpdateDialog
|
|
|
|
{...defaultProps}
|
|
|
|
dialogType={dialogType}
|
2020-02-21 00:09:50 +00:00
|
|
|
didSnooze={didSnooze}
|
2020-02-12 21:30:58 +00:00
|
|
|
hasNetworkDialog={hasNetworkDialog}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.add('Iterations', () => {
|
|
|
|
return permutations.map(({ props, title }) => (
|
|
|
|
<>
|
|
|
|
<h3>{title}</h3>
|
|
|
|
<UpdateDialog {...defaultProps} {...props} />
|
|
|
|
</>
|
|
|
|
));
|
|
|
|
});
|