2021-10-12 23:59:08 +00:00
|
|
|
// Copyright 2020-2021 Signal Messenger, LLC
|
2021-08-19 22:56:29 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import * as React from 'react';
|
|
|
|
import { storiesOf } from '@storybook/react';
|
|
|
|
import { boolean, select } from '@storybook/addon-knobs';
|
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
import { DialogUpdate } from './DialogUpdate';
|
|
|
|
import { DialogType } from '../types/Dialogs';
|
2021-10-12 23:59:08 +00:00
|
|
|
import { WidthBreakpoint } from './_util';
|
|
|
|
import { FakeLeftPaneContainer } from '../test-both/helpers/FakeLeftPaneContainer';
|
2021-08-19 22:56:29 +00:00
|
|
|
|
2021-09-18 00:30:08 +00:00
|
|
|
import { setupI18n } from '../util/setupI18n';
|
2021-08-19 22:56:29 +00:00
|
|
|
import enMessages from '../../_locales/en/messages.json';
|
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
const defaultProps = {
|
2021-10-12 23:59:08 +00:00
|
|
|
containerWidthBreakpoint: WidthBreakpoint.Wide,
|
2021-08-19 22:56:29 +00:00
|
|
|
dismissDialog: action('dismiss-dialog'),
|
|
|
|
downloadSize: 116504357,
|
|
|
|
downloadedSize: 61003110,
|
|
|
|
hasNetworkDialog: false,
|
|
|
|
i18n,
|
|
|
|
didSnooze: false,
|
|
|
|
showEventsCount: 0,
|
|
|
|
snoozeUpdate: action('snooze-update'),
|
|
|
|
startUpdate: action('start-update'),
|
|
|
|
version: 'v7.7.7',
|
|
|
|
};
|
|
|
|
|
|
|
|
const story = storiesOf('Components/DialogUpdate', module);
|
|
|
|
|
|
|
|
story.add('Knobs Playground', () => {
|
2021-10-12 23:59:08 +00:00
|
|
|
const containerWidthBreakpoint = select(
|
|
|
|
'containerWidthBreakpoint',
|
|
|
|
WidthBreakpoint,
|
|
|
|
WidthBreakpoint.Wide
|
|
|
|
);
|
2021-08-19 22:56:29 +00:00
|
|
|
const dialogType = select('dialogType', DialogType, DialogType.Update);
|
|
|
|
const hasNetworkDialog = boolean('hasNetworkDialog', false);
|
|
|
|
const didSnooze = boolean('didSnooze', false);
|
|
|
|
|
|
|
|
return (
|
2021-10-12 23:59:08 +00:00
|
|
|
<FakeLeftPaneContainer containerWidthBreakpoint={containerWidthBreakpoint}>
|
|
|
|
<DialogUpdate
|
|
|
|
{...defaultProps}
|
|
|
|
containerWidthBreakpoint={containerWidthBreakpoint}
|
|
|
|
dialogType={dialogType}
|
|
|
|
didSnooze={didSnooze}
|
|
|
|
hasNetworkDialog={hasNetworkDialog}
|
2021-11-11 22:46:16 +00:00
|
|
|
currentVersion="5.24.0"
|
2021-10-12 23:59:08 +00:00
|
|
|
/>
|
|
|
|
</FakeLeftPaneContainer>
|
2021-08-19 22:56:29 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2021-11-11 22:43:05 +00:00
|
|
|
(
|
|
|
|
[
|
|
|
|
['wide', WidthBreakpoint.Wide],
|
|
|
|
['narrow', WidthBreakpoint.Narrow],
|
|
|
|
] as const
|
|
|
|
).forEach(([name, containerWidthBreakpoint]) => {
|
2021-10-12 23:59:08 +00:00
|
|
|
const defaultPropsForBreakpoint = {
|
|
|
|
...defaultProps,
|
|
|
|
containerWidthBreakpoint,
|
|
|
|
};
|
|
|
|
|
|
|
|
story.add(`Update (${name} container)`, () => (
|
|
|
|
<FakeLeftPaneContainer containerWidthBreakpoint={containerWidthBreakpoint}>
|
|
|
|
<DialogUpdate
|
|
|
|
{...defaultPropsForBreakpoint}
|
|
|
|
dialogType={DialogType.Update}
|
2021-11-11 22:46:16 +00:00
|
|
|
currentVersion="5.24.0"
|
2021-10-12 23:59:08 +00:00
|
|
|
/>
|
|
|
|
</FakeLeftPaneContainer>
|
|
|
|
));
|
2021-08-19 22:56:29 +00:00
|
|
|
|
2021-10-12 23:59:08 +00:00
|
|
|
story.add(`Download Ready (${name} container)`, () => (
|
|
|
|
<FakeLeftPaneContainer containerWidthBreakpoint={containerWidthBreakpoint}>
|
|
|
|
<DialogUpdate
|
|
|
|
{...defaultPropsForBreakpoint}
|
|
|
|
dialogType={DialogType.DownloadReady}
|
2021-11-11 22:46:16 +00:00
|
|
|
currentVersion="5.24.0"
|
2021-10-12 23:59:08 +00:00
|
|
|
/>
|
|
|
|
</FakeLeftPaneContainer>
|
|
|
|
));
|
2021-08-19 22:56:29 +00:00
|
|
|
|
2021-10-12 23:59:08 +00:00
|
|
|
story.add(`Downloading (${name} container)`, () => (
|
|
|
|
<FakeLeftPaneContainer containerWidthBreakpoint={containerWidthBreakpoint}>
|
|
|
|
<DialogUpdate
|
|
|
|
{...defaultPropsForBreakpoint}
|
|
|
|
dialogType={DialogType.Downloading}
|
2021-11-11 22:46:16 +00:00
|
|
|
currentVersion="5.24.0"
|
2021-10-12 23:59:08 +00:00
|
|
|
/>
|
|
|
|
</FakeLeftPaneContainer>
|
|
|
|
));
|
2021-08-19 22:56:29 +00:00
|
|
|
|
2021-10-12 23:59:08 +00:00
|
|
|
story.add(`Cannot Update (${name} container)`, () => (
|
|
|
|
<FakeLeftPaneContainer containerWidthBreakpoint={containerWidthBreakpoint}>
|
|
|
|
<DialogUpdate
|
|
|
|
{...defaultPropsForBreakpoint}
|
|
|
|
dialogType={DialogType.Cannot_Update}
|
2021-11-11 22:46:16 +00:00
|
|
|
currentVersion="5.24.0"
|
|
|
|
/>
|
|
|
|
</FakeLeftPaneContainer>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add(`Cannot Update Beta (${name} container)`, () => (
|
|
|
|
<FakeLeftPaneContainer containerWidthBreakpoint={containerWidthBreakpoint}>
|
|
|
|
<DialogUpdate
|
|
|
|
{...defaultPropsForBreakpoint}
|
|
|
|
dialogType={DialogType.Cannot_Update}
|
|
|
|
currentVersion="5.24.0-beta.1"
|
2021-10-12 23:59:08 +00:00
|
|
|
/>
|
|
|
|
</FakeLeftPaneContainer>
|
|
|
|
));
|
2021-08-19 22:56:29 +00:00
|
|
|
|
2021-10-12 23:59:08 +00:00
|
|
|
story.add(`macOS RO Error (${name} container)`, () => (
|
|
|
|
<FakeLeftPaneContainer containerWidthBreakpoint={containerWidthBreakpoint}>
|
|
|
|
<DialogUpdate
|
|
|
|
{...defaultPropsForBreakpoint}
|
|
|
|
dialogType={DialogType.MacOS_Read_Only}
|
2021-11-11 22:46:16 +00:00
|
|
|
currentVersion="5.24.0"
|
2021-10-12 23:59:08 +00:00
|
|
|
/>
|
|
|
|
</FakeLeftPaneContainer>
|
|
|
|
));
|
|
|
|
});
|