signal-desktop/ts/components/conversation/ContactSpoofingReviewDialog.stories.tsx

68 lines
2.1 KiB
TypeScript
Raw Normal View History

2021-04-21 16:31:12 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
2021-06-01 23:30:25 +00:00
import { times } from 'lodash';
2021-04-21 16:31:12 +00:00
import { action } from '@storybook/addon-actions';
import { storiesOf } from '@storybook/react';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../../util/setupI18n';
2021-04-21 16:31:12 +00:00
import enMessages from '../../../_locales/en/messages.json';
import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation';
import { ContactSpoofingReviewDialog } from './ContactSpoofingReviewDialog';
2021-06-01 23:30:25 +00:00
import { ContactSpoofingType } from '../../util/contactSpoofing';
2021-04-21 16:31:12 +00:00
const i18n = setupI18n('en', enMessages);
const story = storiesOf(
'Components/Conversation/ContactSpoofingReviewDialog',
module
);
2021-06-01 23:30:25 +00:00
const getCommonProps = () => ({
i18n,
onBlock: action('onBlock'),
onBlockAndReportSpam: action('onBlockAndReportSpam'),
onClose: action('onClose'),
onDelete: action('onDelete'),
onShowContactModal: action('onShowContactModal'),
onUnblock: action('onUnblock'),
removeMember: action('removeMember'),
});
story.add('Direct conversations with same title', () => (
2021-04-21 16:31:12 +00:00
<ContactSpoofingReviewDialog
2021-06-01 23:30:25 +00:00
{...getCommonProps()}
type={ContactSpoofingType.DirectConversationWithSameTitle}
2021-04-21 16:31:12 +00:00
possiblyUnsafeConversation={getDefaultConversation()}
safeConversation={getDefaultConversation()}
/>
));
2021-06-01 23:30:25 +00:00
[false, true].forEach(areWeAdmin => {
story.add(
`Group conversation many group members${
areWeAdmin ? " (and we're an admin)" : ''
}`,
() => (
<ContactSpoofingReviewDialog
{...getCommonProps()}
type={ContactSpoofingType.MultipleGroupMembersWithSameTitle}
areWeAdmin={areWeAdmin}
collisionInfoByTitle={{
Alice: times(2, () => ({
oldName: 'Alicia',
conversation: getDefaultConversation({ title: 'Alice' }),
})),
Bob: times(3, () => ({
conversation: getDefaultConversation({ title: 'Bob' }),
})),
Charlie: times(5, () => ({
conversation: getDefaultConversation({ title: 'Charlie' }),
})),
}}
/>
)
);
});