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

101 lines
2.9 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';
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-11-30 10:07:24 +00:00
import { ThemeType } from '../../types/Util';
2021-04-21 16:31:12 +00:00
const i18n = setupI18n('en', enMessages);
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Conversation/ContactSpoofingReviewDialog',
};
2021-04-21 16:31:12 +00:00
2021-06-01 23:30:25 +00:00
const getCommonProps = () => ({
2021-11-30 10:07:24 +00:00
getPreferredBadge: () => undefined,
2021-06-01 23:30:25 +00:00
i18n,
groupConversationId: 'convo-id',
2021-06-01 23:30:25 +00:00
onBlock: action('onBlock'),
onBlockAndReportSpam: action('onBlockAndReportSpam'),
onClose: action('onClose'),
onDelete: action('onDelete'),
onShowContactModal: action('onShowContactModal'),
onUnblock: action('onUnblock'),
removeMember: action('removeMember'),
2021-11-30 10:07:24 +00:00
theme: ThemeType.light,
2021-06-01 23:30:25 +00:00
});
2022-06-07 00:48:02 +00:00
export const DirectConversationsWithSameTitle = (): JSX.Element => (
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()}
/>
2022-06-07 00:48:02 +00:00
);
2021-06-01 23:30:25 +00:00
2022-06-07 00:48:02 +00:00
DirectConversationsWithSameTitle.story = {
name: 'Direct conversations with same title',
};
export const NotAdmin = (): JSX.Element => (
<ContactSpoofingReviewDialog
{...getCommonProps()}
type={ContactSpoofingType.MultipleGroupMembersWithSameTitle}
group={{
...getDefaultConversation(),
areWeAdmin: false,
}}
collisionInfoByTitle={{
Alice: times(2, () => ({
oldName: 'Alicia',
conversation: getDefaultConversation({ title: 'Alice' }),
})),
Bob: times(3, () => ({
conversation: getDefaultConversation({ title: 'Bob' }),
})),
Charlie: times(5, () => ({
conversation: getDefaultConversation({ title: 'Charlie' }),
})),
}}
/>
);
NotAdmin.story = {
name: 'Group conversation many group members',
};
export const Admin = (): JSX.Element => (
<ContactSpoofingReviewDialog
{...getCommonProps()}
type={ContactSpoofingType.MultipleGroupMembersWithSameTitle}
group={{
...getDefaultConversation(),
areWeAdmin: true,
}}
collisionInfoByTitle={{
Alice: times(2, () => ({
oldName: 'Alicia',
conversation: getDefaultConversation({ title: 'Alice' }),
})),
Bob: times(3, () => ({
conversation: getDefaultConversation({ title: 'Bob' }),
})),
Charlie: times(5, () => ({
conversation: getDefaultConversation({ title: 'Charlie' }),
})),
}}
/>
);
Admin.story = {
name: 'Group conversation many group members, and we are admin',
};