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

126 lines
3 KiB
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2020 Signal Messenger, LLC
2020-11-20 17:30:45 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import * as React from 'react';
import type { Meta } from '@storybook/react';
2021-05-07 22:21:10 +00:00
import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../../util/setupI18n';
2020-11-20 17:30:45 +00:00
import enMessages from '../../../_locales/en/messages.json';
import type { PropsType } from './GroupV1Migration';
import { GroupV1Migration } from './GroupV1Migration';
2021-11-20 15:41:21 +00:00
import { ThemeType } from '../../types/Util';
2020-11-20 17:30:45 +00:00
const i18n = setupI18n('en', enMessages);
2021-05-07 22:21:10 +00:00
const contact1 = getDefaultConversation({
2020-11-20 17:30:45 +00:00
title: 'Alice',
2021-05-07 22:21:10 +00:00
phoneNumber: '+1 (300) 555-000',
2020-11-20 17:30:45 +00:00
id: 'guid-1',
2021-05-07 22:21:10 +00:00
});
2020-11-20 17:30:45 +00:00
2021-05-07 22:21:10 +00:00
const contact2 = getDefaultConversation({
2020-11-20 17:30:45 +00:00
title: 'Bob',
2021-05-07 22:21:10 +00:00
phoneNumber: '+1 (300) 555-000',
2020-11-20 17:30:45 +00:00
id: 'guid-2',
2021-05-07 22:21:10 +00:00
});
2020-11-20 17:30:45 +00:00
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Conversation/GroupV1Migration',
argTypes: {
areWeInvited: { control: { type: 'boolean' } },
},
args: {
areWeInvited: false,
conversationId: '123',
droppedMembers: [contact1],
2024-04-30 13:24:21 +00:00
droppedMemberCount: 1,
getPreferredBadge: () => undefined,
i18n,
invitedMembers: [contact2],
2024-04-30 13:24:21 +00:00
invitedMemberCount: 1,
theme: ThemeType.light,
},
} satisfies Meta<PropsType>;
export function YouWereInvited(args: PropsType): JSX.Element {
return <GroupV1Migration {...args} areWeInvited />;
2022-11-18 00:45:19 +00:00
}
export function SingleDroppedAndSingleInvitedMember(
args: PropsType
): JSX.Element {
return <GroupV1Migration {...args} />;
2022-11-18 00:45:19 +00:00
}
2022-06-07 00:48:02 +00:00
export function MultipleDroppedAndInvitedMembers(args: PropsType): JSX.Element {
2022-11-18 00:45:19 +00:00
return (
<GroupV1Migration
{...args}
invitedMembers={[contact1, contact2]}
2024-04-30 13:24:21 +00:00
invitedMemberCount={3}
droppedMembers={[contact1, contact2]}
2024-04-30 13:24:21 +00:00
droppedMemberCount={3}
2022-11-18 00:45:19 +00:00
/>
);
}
2022-06-07 00:48:02 +00:00
export function JustInvitedMembers(args: PropsType): JSX.Element {
2022-11-18 00:45:19 +00:00
return (
<GroupV1Migration
{...args}
invitedMembers={[contact1, contact1, contact2, contact2]}
2024-04-30 13:24:21 +00:00
invitedMemberCount={4}
droppedMembers={[]}
2024-04-30 13:24:21 +00:00
droppedMemberCount={0}
2022-11-18 00:45:19 +00:00
/>
);
}
2020-11-20 17:30:45 +00:00
export function JustDroppedMembers(args: PropsType): JSX.Element {
2022-11-18 00:45:19 +00:00
return (
<GroupV1Migration
{...args}
invitedMembers={[]}
2024-04-30 13:24:21 +00:00
invitedMemberCount={0}
droppedMembers={[contact1, contact1, contact2, contact2]}
2024-04-30 13:24:21 +00:00
droppedMemberCount={4}
2022-11-18 00:45:19 +00:00
/>
);
}
2022-06-07 00:48:02 +00:00
export function NoDroppedOrInvitedMembers(args: PropsType): JSX.Element {
2024-04-30 13:24:21 +00:00
return (
<GroupV1Migration
{...args}
invitedMembers={[]}
invitedMemberCount={0}
droppedMembers={[]}
droppedMemberCount={0}
/>
);
}
export function NoArraysCountIsZero(args: PropsType): JSX.Element {
return (
<GroupV1Migration
{...args}
invitedMembers={undefined}
invitedMemberCount={0}
droppedMembers={undefined}
droppedMemberCount={0}
/>
);
}
export function NoArraysWithCount(args: PropsType): JSX.Element {
return (
<GroupV1Migration
{...args}
invitedMembers={undefined}
invitedMemberCount={4}
droppedMembers={undefined}
droppedMemberCount={2}
/>
);
2022-11-18 00:45:19 +00:00
}