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

97 lines
3 KiB
TypeScript
Raw Normal View History

2021-04-21 11:31:12 -05:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
2021-06-01 18:30:25 -05:00
import { times } from 'lodash';
2021-04-21 11:31:12 -05:00
import { action } from '@storybook/addon-actions';
import type { Meta } from '@storybook/react';
2021-09-17 20:30:08 -04:00
import { setupI18n } from '../../util/setupI18n';
2021-04-21 11:31:12 -05:00
import enMessages from '../../../_locales/en/messages.json';
import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation';
import type { PropsType } from './ContactSpoofingReviewDialog';
2021-04-21 11:31:12 -05:00
import { ContactSpoofingReviewDialog } from './ContactSpoofingReviewDialog';
2021-06-01 18:30:25 -05:00
import { ContactSpoofingType } from '../../util/contactSpoofing';
2021-11-30 04:07:24 -06:00
import { ThemeType } from '../../types/Util';
2021-04-21 11:31:12 -05:00
const i18n = setupI18n('en', enMessages);
2022-06-06 20:48:02 -04:00
export default {
title: 'Components/Conversation/ContactSpoofingReviewDialog',
} satisfies Meta<PropsType>;
2021-04-21 11:31:12 -05:00
2021-06-01 18:30:25 -05:00
const getCommonProps = () => ({
2022-12-06 14:03:09 -05:00
acceptConversation: action('acceptConversation'),
blockAndReportSpam: action('blockAndReportSpam'),
blockConversation: action('blockConversation'),
conversationId: 'some-conversation-id',
2022-12-06 14:03:09 -05:00
deleteConversation: action('deleteConversation'),
2021-11-30 04:07:24 -06:00
getPreferredBadge: () => undefined,
groupConversationId: 'convo-id',
2022-12-06 14:03:09 -05:00
i18n,
2021-06-01 18:30:25 -05:00
onClose: action('onClose'),
showContactModal: action('showContactModal'),
2021-06-01 18:30:25 -05:00
removeMember: action('removeMember'),
2021-11-30 04:07:24 -06:00
theme: ThemeType.light,
2021-06-01 18:30:25 -05:00
});
2022-11-17 16:45:19 -08:00
export function DirectConversationsWithSameTitle(): JSX.Element {
return (
<ContactSpoofingReviewDialog
{...getCommonProps()}
type={ContactSpoofingType.DirectConversationWithSameTitle}
possiblyUnsafeConversation={getDefaultConversation()}
safeConversation={getDefaultConversation()}
/>
);
}
2021-06-01 18:30:25 -05:00
2022-11-17 16:45:19 -08: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-06 20:48:02 -04:00
2022-11-17 16:45:19 -08: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' }),
})),
}}
/>
);
}