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

165 lines
4.8 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 type { Meta } 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 type { PropsType } from './ContactSpoofingReviewDialog';
2021-04-21 16:31:12 +00:00
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',
} satisfies Meta<PropsType>;
2021-04-21 16:31:12 +00:00
2021-06-01 23:30:25 +00:00
const getCommonProps = () => ({
2022-12-06 19:03:09 +00:00
acceptConversation: action('acceptConversation'),
2024-03-12 16:29:31 +00:00
reportSpam: action('reportSpam'),
2022-12-06 19:03:09 +00:00
blockAndReportSpam: action('blockAndReportSpam'),
blockConversation: action('blockConversation'),
conversationId: 'some-conversation-id',
2022-12-06 19:03:09 +00:00
deleteConversation: action('deleteConversation'),
2021-11-30 10:07:24 +00:00
getPreferredBadge: () => undefined,
groupConversationId: 'convo-id',
2022-12-06 19:03:09 +00:00
i18n,
2021-06-01 23:30:25 +00:00
onClose: action('onClose'),
showContactModal: action('showContactModal'),
toggleSignalConnectionsModal: action('toggleSignalConnectionsModal'),
updateSharedGroups: action('updateSharedGroups'),
2021-06-01 23:30:25 +00:00
removeMember: action('removeMember'),
2021-11-30 10:07:24 +00:00
theme: ThemeType.light,
2021-06-01 23:30:25 +00:00
});
2022-11-18 00:45:19 +00:00
export function DirectConversationsWithSameTitle(): JSX.Element {
return (
<ContactSpoofingReviewDialog
{...getCommonProps()}
type={ContactSpoofingType.DirectConversationWithSameTitle}
possiblyUnsafe={{
conversation: getDefaultConversation(),
isSignalConnection: false,
}}
safe={{
conversation: getDefaultConversation(),
isSignalConnection: true,
}}
2022-11-18 00:45:19 +00:00
/>
);
}
2021-06-01 23:30:25 +00:00
export function NotAdminMany(): JSX.Element {
2022-11-18 00:45:19 +00:00
return (
<ContactSpoofingReviewDialog
{...getCommonProps()}
type={ContactSpoofingType.MultipleGroupMembersWithSameTitle}
group={{
...getDefaultConversation(),
areWeAdmin: false,
}}
collisionInfoByTitle={{
Alice: times(2, () => ({
oldName: 'Alicia',
isSignalConnection: false,
2022-11-18 00:45:19 +00:00
conversation: getDefaultConversation({ title: 'Alice' }),
})),
Bob: times(3, () => ({
isSignalConnection: false,
2022-11-18 00:45:19 +00:00
conversation: getDefaultConversation({ title: 'Bob' }),
})),
Charlie: times(5, () => ({
isSignalConnection: false,
2022-11-18 00:45:19 +00:00
conversation: getDefaultConversation({ title: 'Charlie' }),
})),
}}
/>
);
}
2022-06-07 00:48:02 +00:00
export function NotAdminOne(): JSX.Element {
return (
<ContactSpoofingReviewDialog
{...getCommonProps()}
type={ContactSpoofingType.MultipleGroupMembersWithSameTitle}
group={{
...getDefaultConversation(),
areWeAdmin: false,
}}
collisionInfoByTitle={{
Alice: [
{
oldName: 'Alicia',
isSignalConnection: false,
conversation: getDefaultConversation({ title: 'Alice' }),
},
{
oldName: 'Alice',
isSignalConnection: true,
conversation: getDefaultConversation({ title: 'Alice' }),
},
],
}}
/>
);
}
export function AdminMany(): JSX.Element {
2022-11-18 00:45:19 +00:00
return (
<ContactSpoofingReviewDialog
{...getCommonProps()}
type={ContactSpoofingType.MultipleGroupMembersWithSameTitle}
group={{
...getDefaultConversation(),
areWeAdmin: true,
}}
collisionInfoByTitle={{
Alice: times(2, () => ({
oldName: 'Alicia',
isSignalConnection: false,
2022-11-18 00:45:19 +00:00
conversation: getDefaultConversation({ title: 'Alice' }),
})),
Bob: times(3, () => ({
isSignalConnection: false,
2022-11-18 00:45:19 +00:00
conversation: getDefaultConversation({ title: 'Bob' }),
})),
Charlie: times(5, () => ({
isSignalConnection: false,
2022-11-18 00:45:19 +00:00
conversation: getDefaultConversation({ title: 'Charlie' }),
})),
}}
/>
);
}
export function AdminOne(): JSX.Element {
return (
<ContactSpoofingReviewDialog
{...getCommonProps()}
type={ContactSpoofingType.MultipleGroupMembersWithSameTitle}
group={{
...getDefaultConversation(),
areWeAdmin: true,
}}
collisionInfoByTitle={{
Alice: [
{
oldName: 'Alicia',
isSignalConnection: false,
conversation: getDefaultConversation({ title: 'Alice' }),
},
{
isSignalConnection: true,
conversation: getDefaultConversation({ title: 'Alice' }),
},
],
}}
/>
);
}