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

116 lines
2.8 KiB
TypeScript
Raw Normal View History

2022-06-03 21:07:51 +00:00
// Copyright 2020-2022 Signal Messenger, LLC
2020-11-20 17:30:45 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import * as React from 'react';
import { isBoolean } from 'lodash';
import { boolean } from '@storybook/addon-knobs';
2020-11-20 17:30:45 +00:00
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
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
areWeInvited: boolean(
'areWeInvited',
isBoolean(overrideProps.areWeInvited) ? overrideProps.areWeInvited : false
),
2020-11-20 17:30:45 +00:00
droppedMembers: overrideProps.droppedMembers || [contact1],
2021-11-20 15:41:21 +00:00
getPreferredBadge: () => undefined,
2020-11-20 17:30:45 +00:00
i18n,
invitedMembers: overrideProps.invitedMembers || [contact2],
2021-11-20 15:41:21 +00:00
theme: ThemeType.light,
2020-11-20 17:30:45 +00:00
});
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Conversation/GroupV1Migration',
};
2020-11-20 17:30:45 +00:00
2022-06-07 00:48:02 +00:00
export const YouWereInvited = (): JSX.Element => (
<GroupV1Migration
{...createProps({
areWeInvited: true,
})}
/>
2022-06-07 00:48:02 +00:00
);
2022-06-07 00:48:02 +00:00
YouWereInvited.story = {
name: 'You were invited',
};
export const SingleDroppedAndSingleInvitedMember = (): JSX.Element => (
2020-11-20 17:30:45 +00:00
<GroupV1Migration {...createProps()} />
2022-06-07 00:48:02 +00:00
);
SingleDroppedAndSingleInvitedMember.story = {
name: 'Single dropped and single invited member',
};
2020-11-20 17:30:45 +00:00
2022-06-07 00:48:02 +00:00
export const MultipleDroppedAndInvitedMembers = (): JSX.Element => (
2020-11-20 17:30:45 +00:00
<GroupV1Migration
{...createProps({
invitedMembers: [contact1, contact2],
droppedMembers: [contact1, contact2],
})}
/>
2022-06-07 00:48:02 +00:00
);
MultipleDroppedAndInvitedMembers.story = {
name: 'Multiple dropped and invited members',
};
2020-11-20 17:30:45 +00:00
2022-06-07 00:48:02 +00:00
export const JustInvitedMembers = (): JSX.Element => (
2020-11-20 17:30:45 +00:00
<GroupV1Migration
{...createProps({
invitedMembers: [contact1, contact1, contact2, contact2],
droppedMembers: [],
})}
/>
2022-06-07 00:48:02 +00:00
);
2020-11-20 17:30:45 +00:00
2022-06-07 00:48:02 +00:00
JustInvitedMembers.story = {
name: 'Just invited members',
};
export const JustDroppedMembers = (): JSX.Element => (
2020-11-20 17:30:45 +00:00
<GroupV1Migration
{...createProps({
invitedMembers: [],
droppedMembers: [contact1, contact1, contact2, contact2],
})}
/>
2022-06-07 00:48:02 +00:00
);
JustDroppedMembers.story = {
name: 'Just dropped members',
};
2020-11-20 17:30:45 +00:00
2022-06-07 00:48:02 +00:00
export const NoDroppedOrInvitedMembers = (): JSX.Element => (
2020-11-20 17:30:45 +00:00
<GroupV1Migration
{...createProps({
invitedMembers: [],
droppedMembers: [],
})}
/>
2022-06-07 00:48:02 +00:00
);
NoDroppedOrInvitedMembers.story = {
name: 'No dropped or invited members',
};