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

97 lines
3 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'),
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'),
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}
possiblyUnsafeConversation={getDefaultConversation()}
safeConversation={getDefaultConversation()}
/>
);
}
2021-06-01 23:30:25 +00:00
2022-11-18 00:45:19 +00:00
export function NotAdmin(): JSX.Element {
return (
<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' }),
})),
}}
/>
);
}
2022-06-07 00:48:02 +00:00
2022-11-18 00:45:19 +00:00
export function Admin(): JSX.Element {
return (
<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' }),
})),
}}
/>
);
}