2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-06-26 00:08:58 +00:00
|
|
|
import * as React from 'react';
|
2020-09-12 00:46:52 +00:00
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
|
2020-06-26 00:08:58 +00:00
|
|
|
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';
|
2020-06-26 00:08:58 +00:00
|
|
|
import enMessages from '../../_locales/en/messages.json';
|
2021-11-17 21:58:34 +00:00
|
|
|
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext';
|
|
|
|
import { getFakeBadge } from '../test-both/helpers/getFakeBadge';
|
2022-11-11 04:10:30 +00:00
|
|
|
import { MY_STORY_ID } from '../types/Stories';
|
2020-06-26 00:08:58 +00:00
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
2021-05-07 22:21:10 +00:00
|
|
|
const contactWithAllData = getDefaultConversation({
|
2021-04-27 19:29:59 +00:00
|
|
|
id: 'abc',
|
2020-06-26 00:08:58 +00:00
|
|
|
avatarPath: undefined,
|
2020-07-24 01:35:32 +00:00
|
|
|
profileName: '-*Smartest Dude*-',
|
2020-07-29 23:20:05 +00:00
|
|
|
title: 'Rick Sanchez',
|
2020-06-26 00:08:58 +00:00
|
|
|
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
|
|
|
|
2022-11-02 00:10:27 +00:00
|
|
|
const contactWithJustProfileVerified = getDefaultConversation({
|
2021-04-27 19:29:59 +00:00
|
|
|
id: 'def',
|
2020-07-24 01:35:32 +00:00
|
|
|
avatarPath: undefined,
|
2020-07-29 23:20:05 +00:00
|
|
|
title: '-*Smartest Dude*-',
|
2020-07-24 01:35:32 +00:00
|
|
|
profileName: '-*Smartest Dude*-',
|
|
|
|
name: undefined,
|
|
|
|
phoneNumber: '(305) 123-4567',
|
2022-11-02 00:10:27 +00:00
|
|
|
isVerified: true,
|
2021-05-07 22:21:10 +00:00
|
|
|
});
|
2020-07-24 01:35:32 +00:00
|
|
|
|
2022-11-02 00:10:27 +00:00
|
|
|
const contactWithJustNumberVerified = getDefaultConversation({
|
2021-04-27 19:29:59 +00:00
|
|
|
id: 'xyz',
|
2020-07-24 01:35:32 +00:00
|
|
|
avatarPath: undefined,
|
|
|
|
profileName: undefined,
|
|
|
|
name: undefined,
|
2020-07-29 23:20:05 +00:00
|
|
|
title: '(305) 123-4567',
|
2020-07-24 01:35:32 +00:00
|
|
|
phoneNumber: '(305) 123-4567',
|
2022-11-02 00:10:27 +00:00
|
|
|
isVerified: true,
|
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,
|
2020-07-29 23:20:05 +00:00
|
|
|
title: 'Unknown contact',
|
2021-05-07 22:21:10 +00:00
|
|
|
});
|
2020-06-26 00:08:58 +00:00
|
|
|
|
2021-11-17 21:58:34 +00:00
|
|
|
const useTheme = () => React.useContext(StorybookThemeContext);
|
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export default {
|
|
|
|
title: 'Components/SafetyNumberChangeDialog',
|
|
|
|
};
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function SingleContactDialog(): JSX.Element {
|
2022-06-07 00:48:02 +00:00
|
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
|
|
<SafetyNumberChangeDialog
|
2022-11-11 04:10:30 +00:00
|
|
|
contacts={[
|
|
|
|
{
|
|
|
|
story: undefined,
|
|
|
|
contacts: [contactWithAllData],
|
|
|
|
},
|
|
|
|
]}
|
2022-06-07 00:48:02 +00:00
|
|
|
getPreferredBadge={() => undefined}
|
|
|
|
i18n={i18n}
|
|
|
|
onCancel={action('cancel')}
|
|
|
|
onConfirm={action('confirm')}
|
2022-11-11 04:10:30 +00:00
|
|
|
removeFromStory={action('removeFromStory')}
|
2022-06-07 00:48:02 +00:00
|
|
|
renderSafetyNumber={() => {
|
|
|
|
action('renderSafetyNumber');
|
|
|
|
return <div>This is a mock Safety Number View</div>;
|
|
|
|
}}
|
|
|
|
theme={theme}
|
|
|
|
/>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function DifferentConfirmationText(): JSX.Element {
|
2022-06-07 00:48:02 +00:00
|
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
|
|
<SafetyNumberChangeDialog
|
|
|
|
confirmText="You are awesome"
|
2022-11-11 04:10:30 +00:00
|
|
|
contacts={[
|
|
|
|
{
|
|
|
|
story: undefined,
|
|
|
|
contacts: [contactWithAllData],
|
|
|
|
},
|
|
|
|
]}
|
2022-06-07 00:48:02 +00:00
|
|
|
getPreferredBadge={() => undefined}
|
|
|
|
i18n={i18n}
|
|
|
|
onCancel={action('cancel')}
|
|
|
|
onConfirm={action('confirm')}
|
2022-11-11 04:10:30 +00:00
|
|
|
removeFromStory={action('removeFromStory')}
|
2022-06-07 00:48:02 +00:00
|
|
|
renderSafetyNumber={() => {
|
|
|
|
action('renderSafetyNumber');
|
|
|
|
return <div>This is a mock Safety Number View</div>;
|
|
|
|
}}
|
|
|
|
theme={theme}
|
|
|
|
/>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function MultiContactDialog(): JSX.Element {
|
2022-06-07 00:48:02 +00:00
|
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
|
|
<SafetyNumberChangeDialog
|
|
|
|
contacts={[
|
2022-11-11 04:10:30 +00:00
|
|
|
{
|
|
|
|
story: undefined,
|
|
|
|
contacts: [contactWithAllData, contactWithJustProfileVerified],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
story: undefined,
|
|
|
|
contacts: [contactWithJustNumberVerified, contactWithNothing],
|
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
]}
|
|
|
|
getPreferredBadge={() => undefined}
|
|
|
|
i18n={i18n}
|
|
|
|
onCancel={action('cancel')}
|
|
|
|
onConfirm={action('confirm')}
|
2022-11-11 04:10:30 +00:00
|
|
|
removeFromStory={action('removeFromStory')}
|
2022-06-07 00:48:02 +00:00
|
|
|
renderSafetyNumber={() => {
|
|
|
|
action('renderSafetyNumber');
|
|
|
|
return <div>This is a mock Safety Number View</div>;
|
|
|
|
}}
|
|
|
|
theme={theme}
|
|
|
|
/>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function AllVerified(): JSX.Element {
|
2022-11-02 00:10:27 +00:00
|
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
|
|
<SafetyNumberChangeDialog
|
2022-11-11 04:10:30 +00:00
|
|
|
contacts={[
|
|
|
|
{
|
|
|
|
story: undefined,
|
|
|
|
contacts: [
|
|
|
|
contactWithJustProfileVerified,
|
|
|
|
contactWithJustNumberVerified,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]}
|
2022-11-02 00:10:27 +00:00
|
|
|
getPreferredBadge={() => undefined}
|
|
|
|
i18n={i18n}
|
|
|
|
onCancel={action('cancel')}
|
|
|
|
onConfirm={action('confirm')}
|
2022-11-11 04:10:30 +00:00
|
|
|
removeFromStory={action('removeFromStory')}
|
2022-11-02 00:10:27 +00:00
|
|
|
renderSafetyNumber={() => {
|
|
|
|
action('renderSafetyNumber');
|
|
|
|
return <div>This is a mock Safety Number View</div>;
|
|
|
|
}}
|
|
|
|
theme={theme}
|
|
|
|
/>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-11-02 00:10:27 +00:00
|
|
|
AllVerified.story = {
|
|
|
|
name: 'All verified; Send button instead',
|
|
|
|
};
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function MultipleContactsAllWithBadges(): JSX.Element {
|
2022-06-07 00:48:02 +00:00
|
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
|
|
<SafetyNumberChangeDialog
|
|
|
|
contacts={[
|
2022-11-11 04:10:30 +00:00
|
|
|
{
|
|
|
|
story: undefined,
|
|
|
|
contacts: [
|
|
|
|
contactWithAllData,
|
|
|
|
contactWithJustProfileVerified,
|
|
|
|
contactWithJustNumberVerified,
|
|
|
|
contactWithNothing,
|
|
|
|
],
|
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
]}
|
|
|
|
getPreferredBadge={() => getFakeBadge()}
|
|
|
|
i18n={i18n}
|
|
|
|
onCancel={action('cancel')}
|
|
|
|
onConfirm={action('confirm')}
|
2022-11-11 04:10:30 +00:00
|
|
|
removeFromStory={action('removeFromStory')}
|
2022-06-07 00:48:02 +00:00
|
|
|
renderSafetyNumber={() => {
|
|
|
|
action('renderSafetyNumber');
|
|
|
|
return <div>This is a mock Safety Number View</div>;
|
|
|
|
}}
|
|
|
|
theme={theme}
|
|
|
|
/>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
|
|
|
MultipleContactsAllWithBadges.story = {
|
|
|
|
name: 'Multiple contacts, all with badges',
|
|
|
|
};
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function TenContacts(): JSX.Element {
|
2022-06-07 00:48:02 +00:00
|
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
|
|
<SafetyNumberChangeDialog
|
|
|
|
contacts={[
|
2022-11-11 04:10:30 +00:00
|
|
|
{
|
|
|
|
story: undefined,
|
|
|
|
contacts: [
|
|
|
|
contactWithAllData,
|
|
|
|
contactWithJustProfileVerified,
|
|
|
|
contactWithJustNumberVerified,
|
|
|
|
contactWithNothing,
|
|
|
|
contactWithAllData,
|
|
|
|
contactWithAllData,
|
|
|
|
contactWithAllData,
|
|
|
|
contactWithAllData,
|
|
|
|
contactWithAllData,
|
|
|
|
contactWithAllData,
|
|
|
|
],
|
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
]}
|
|
|
|
getPreferredBadge={() => undefined}
|
|
|
|
i18n={i18n}
|
|
|
|
onCancel={action('cancel')}
|
|
|
|
onConfirm={action('confirm')}
|
2022-11-11 04:10:30 +00:00
|
|
|
removeFromStory={action('removeFromStory')}
|
2022-06-07 00:48:02 +00:00
|
|
|
renderSafetyNumber={() => {
|
|
|
|
action('renderSafetyNumber');
|
|
|
|
return <div>This is a mock Safety Number View</div>;
|
|
|
|
}}
|
|
|
|
theme={theme}
|
|
|
|
/>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-11-02 00:10:27 +00:00
|
|
|
|
|
|
|
TenContacts.story = {
|
|
|
|
name: 'Ten contacts; first isReviewing = false, then scrolling dialog',
|
|
|
|
};
|
2022-11-11 04:10:30 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function NoContacts(): JSX.Element {
|
2022-11-11 04:10:30 +00:00
|
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
|
|
<SafetyNumberChangeDialog
|
|
|
|
contacts={[
|
|
|
|
{
|
|
|
|
story: {
|
|
|
|
name: 'My Story',
|
|
|
|
conversationId: 'our-conversation-id',
|
|
|
|
distributionId: MY_STORY_ID,
|
|
|
|
},
|
|
|
|
contacts: [],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
story: {
|
|
|
|
name: 'Custom List A',
|
|
|
|
conversationId: 'our-conversation-id',
|
|
|
|
distributionId: 'some-other-distribution-id',
|
|
|
|
},
|
|
|
|
contacts: [],
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
getPreferredBadge={() => undefined}
|
|
|
|
i18n={i18n}
|
|
|
|
onCancel={action('cancel')}
|
|
|
|
onConfirm={action('confirm')}
|
|
|
|
removeFromStory={action('removeFromStory')}
|
|
|
|
renderSafetyNumber={() => {
|
|
|
|
action('renderSafetyNumber');
|
|
|
|
return <div>This is a mock Safety Number View</div>;
|
|
|
|
}}
|
|
|
|
theme={theme}
|
|
|
|
/>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-11-11 04:10:30 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function InMultipleStories(): JSX.Element {
|
2022-11-11 04:10:30 +00:00
|
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
|
|
<SafetyNumberChangeDialog
|
|
|
|
contacts={[
|
|
|
|
{
|
|
|
|
story: {
|
|
|
|
name: 'Not to be trusted',
|
|
|
|
conversationId: 'our-conversation-id',
|
|
|
|
distributionId: MY_STORY_ID,
|
|
|
|
},
|
|
|
|
contacts: [contactWithAllData, contactWithJustProfileVerified],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
story: {
|
|
|
|
name: 'Custom List A',
|
|
|
|
conversationId: 'our-conversation-id',
|
|
|
|
distributionId: 'some-other-distribution-id',
|
|
|
|
},
|
|
|
|
contacts: [
|
|
|
|
contactWithAllData,
|
|
|
|
contactWithAllData,
|
|
|
|
contactWithAllData,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
story: {
|
|
|
|
name: 'Hiking Buds',
|
|
|
|
conversationId: 'hiking-group-id',
|
|
|
|
},
|
|
|
|
contacts: [
|
|
|
|
contactWithJustNumberVerified,
|
|
|
|
contactWithAllData,
|
|
|
|
contactWithAllData,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
getPreferredBadge={() => undefined}
|
|
|
|
i18n={i18n}
|
|
|
|
onCancel={action('cancel')}
|
|
|
|
onConfirm={action('confirm')}
|
|
|
|
removeFromStory={action('removeFromStory')}
|
|
|
|
renderSafetyNumber={() => {
|
|
|
|
action('renderSafetyNumber');
|
|
|
|
return <div>This is a mock Safety Number View</div>;
|
|
|
|
}}
|
|
|
|
theme={theme}
|
|
|
|
/>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|