signal-desktop/ts/components/SafetyNumberChangeDialog.stories.tsx

125 lines
3.3 KiB
TypeScript
Raw Normal View History

2021-05-07 22:21:10 +00:00
// Copyright 2020-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import * as React from 'react';
2020-09-12 00:46:52 +00:00
import { action } from '@storybook/addon-actions';
import { storiesOf } from '@storybook/react';
import { SafetyNumberChangeDialog } from './SafetyNumberChangeDialog';
2021-05-07 22:21:10 +00:00
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../util/setupI18n';
import enMessages from '../../_locales/en/messages.json';
const i18n = setupI18n('en', enMessages);
2021-05-07 22:21:10 +00:00
const contactWithAllData = getDefaultConversation({
id: 'abc',
avatarPath: undefined,
2020-07-24 01:35:32 +00:00
profileName: '-*Smartest Dude*-',
title: 'Rick Sanchez',
name: 'Rick Sanchez',
2020-07-24 01:35:32 +00:00
phoneNumber: '(305) 123-4567',
2021-05-07 22:21:10 +00:00
});
2020-07-24 01:35:32 +00:00
2021-05-07 22:21:10 +00:00
const contactWithJustProfile = getDefaultConversation({
id: 'def',
2020-07-24 01:35:32 +00:00
avatarPath: undefined,
title: '-*Smartest Dude*-',
2020-07-24 01:35:32 +00:00
profileName: '-*Smartest Dude*-',
name: undefined,
phoneNumber: '(305) 123-4567',
2021-05-07 22:21:10 +00:00
});
2020-07-24 01:35:32 +00:00
2021-05-07 22:21:10 +00:00
const contactWithJustNumber = getDefaultConversation({
id: 'xyz',
2020-07-24 01:35:32 +00:00
avatarPath: undefined,
profileName: undefined,
name: undefined,
title: '(305) 123-4567',
2020-07-24 01:35:32 +00:00
phoneNumber: '(305) 123-4567',
2021-05-07 22:21:10 +00:00
});
2020-07-24 01:35:32 +00:00
2021-05-07 22:21:10 +00:00
const contactWithNothing = getDefaultConversation({
2020-07-24 01:35:32 +00:00
id: 'some-guid',
avatarPath: undefined,
profileName: undefined,
name: undefined,
phoneNumber: undefined,
title: 'Unknown contact',
2021-05-07 22:21:10 +00:00
});
storiesOf('Components/SafetyNumberChangeDialog', module)
.add('Single Contact Dialog', () => {
return (
<SafetyNumberChangeDialog
2020-07-24 01:35:32 +00:00
contacts={[contactWithAllData]}
i18n={i18n}
onCancel={action('cancel')}
onConfirm={action('confirm')}
renderSafetyNumber={() => {
action('renderSafetyNumber');
return <div>This is a mock Safety Number View</div>;
}}
/>
);
})
.add('Different Confirmation Text', () => {
return (
<SafetyNumberChangeDialog
confirmText="You are awesome"
contacts={[contactWithAllData]}
i18n={i18n}
onCancel={action('cancel')}
onConfirm={action('confirm')}
renderSafetyNumber={() => {
action('renderSafetyNumber');
return <div>This is a mock Safety Number View</div>;
}}
/>
);
})
.add('Multi Contact Dialog', () => {
return (
<SafetyNumberChangeDialog
2020-07-24 01:35:32 +00:00
contacts={[
contactWithAllData,
contactWithJustProfile,
contactWithJustNumber,
contactWithNothing,
]}
i18n={i18n}
onCancel={action('cancel')}
onConfirm={action('confirm')}
renderSafetyNumber={() => {
action('renderSafetyNumber');
return <div>This is a mock Safety Number View</div>;
}}
/>
);
})
.add('Scroll Dialog', () => {
return (
<SafetyNumberChangeDialog
contacts={[
2020-07-24 01:35:32 +00:00
contactWithAllData,
contactWithJustProfile,
contactWithJustNumber,
contactWithNothing,
contactWithAllData,
contactWithAllData,
contactWithAllData,
contactWithAllData,
contactWithAllData,
contactWithAllData,
]}
i18n={i18n}
onCancel={action('cancel')}
onConfirm={action('confirm')}
renderSafetyNumber={() => {
action('renderSafetyNumber');
return <div>This is a mock Safety Number View</div>;
}}
/>
);
});