2021-05-07 22:21:10 +00:00
|
|
|
// Copyright 2020-2021 Signal Messenger, LLC
|
2020-11-20 17:30:45 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import * as React from 'react';
|
2022-07-15 21:50:02 +00:00
|
|
|
|
2020-11-20 17:30:45 +00:00
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { PropsType } from './GroupV1MigrationDialog';
|
|
|
|
import { GroupV1MigrationDialog } from './GroupV1MigrationDialog';
|
|
|
|
import type { ConversationType } from '../state/ducks/conversations';
|
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';
|
2021-05-07 22:21:10 +00:00
|
|
|
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation';
|
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: ConversationType = getDefaultConversation({
|
2020-11-20 17:30:45 +00:00
|
|
|
title: 'Alice',
|
2021-05-07 22:21:10 +00:00
|
|
|
phoneNumber: '+1 (300) 555-0000',
|
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: ConversationType = getDefaultConversation({
|
2020-11-20 17:30:45 +00:00
|
|
|
title: 'Bob',
|
2021-05-07 22:21:10 +00:00
|
|
|
phoneNumber: '+1 (300) 555-0001',
|
2020-12-03 16:03:21 +00:00
|
|
|
id: 'guid-2',
|
2021-05-07 22:21:10 +00:00
|
|
|
});
|
2020-12-03 16:03:21 +00:00
|
|
|
|
2021-05-07 22:21:10 +00:00
|
|
|
const contact3: ConversationType = getDefaultConversation({
|
2020-12-03 16:03:21 +00:00
|
|
|
title: 'Chet',
|
2021-05-07 22:21:10 +00:00
|
|
|
phoneNumber: '+1 (300) 555-0002',
|
2020-12-03 16:03:21 +00:00
|
|
|
id: 'guid-3',
|
2021-05-07 22:21:10 +00:00
|
|
|
});
|
2020-11-20 17:30:45 +00:00
|
|
|
|
|
|
|
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
|
2022-07-15 21:50:02 +00:00
|
|
|
areWeInvited: Boolean(overrideProps.areWeInvited),
|
2020-12-03 16:03:21 +00:00
|
|
|
droppedMembers: overrideProps.droppedMembers || [contact3, contact1],
|
2021-11-20 15:41:21 +00:00
|
|
|
getPreferredBadge: () => undefined,
|
2022-07-15 21:50:02 +00:00
|
|
|
hasMigrated: Boolean(overrideProps.hasMigrated),
|
2020-11-20 17:30:45 +00:00
|
|
|
i18n,
|
|
|
|
invitedMembers: overrideProps.invitedMembers || [contact2],
|
|
|
|
migrate: action('migrate'),
|
|
|
|
onClose: action('onClose'),
|
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/GroupV1MigrationDialog',
|
|
|
|
};
|
2020-11-20 17:30:45 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const NotYetMigratedBasic = (): JSX.Element => {
|
2020-11-20 17:30:45 +00:00
|
|
|
return <GroupV1MigrationDialog {...createProps()} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
NotYetMigratedBasic.story = {
|
|
|
|
name: 'Not yet migrated, basic',
|
|
|
|
};
|
2020-11-20 17:30:45 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const MigratedBasic = (): JSX.Element => {
|
2020-11-20 17:30:45 +00:00
|
|
|
return (
|
|
|
|
<GroupV1MigrationDialog
|
|
|
|
{...createProps({
|
|
|
|
hasMigrated: true,
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
);
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2020-11-20 17:30:45 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
MigratedBasic.story = {
|
|
|
|
name: 'Migrated, basic',
|
|
|
|
};
|
|
|
|
|
|
|
|
export const MigratedYouAreInvited = (): JSX.Element => {
|
2020-12-01 23:45:39 +00:00
|
|
|
return (
|
|
|
|
<GroupV1MigrationDialog
|
|
|
|
{...createProps({
|
|
|
|
hasMigrated: true,
|
|
|
|
areWeInvited: true,
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
);
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2020-12-01 23:45:39 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
MigratedYouAreInvited.story = {
|
|
|
|
name: 'Migrated, you are invited',
|
|
|
|
};
|
|
|
|
|
|
|
|
export const NotYetMigratedMultipleDroppedAndInvitedMembers =
|
|
|
|
(): JSX.Element => {
|
|
|
|
return (
|
|
|
|
<GroupV1MigrationDialog
|
|
|
|
{...createProps({
|
|
|
|
droppedMembers: [contact3, contact1, contact2],
|
|
|
|
invitedMembers: [contact2, contact3, contact1],
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
NotYetMigratedMultipleDroppedAndInvitedMembers.story = {
|
|
|
|
name: 'Not yet migrated, multiple dropped and invited members',
|
|
|
|
};
|
2020-11-20 17:30:45 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const NotYetMigratedNoMembers = (): JSX.Element => {
|
2020-11-20 17:30:45 +00:00
|
|
|
return (
|
|
|
|
<GroupV1MigrationDialog
|
|
|
|
{...createProps({
|
|
|
|
droppedMembers: [],
|
|
|
|
invitedMembers: [],
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
);
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
NotYetMigratedNoMembers.story = {
|
|
|
|
name: 'Not yet migrated, no members',
|
|
|
|
};
|
2020-11-20 17:30:45 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const NotYetMigratedJustDroppedMember = (): JSX.Element => {
|
2020-11-20 17:30:45 +00:00
|
|
|
return (
|
|
|
|
<GroupV1MigrationDialog
|
|
|
|
{...createProps({
|
|
|
|
invitedMembers: [],
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
);
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
NotYetMigratedJustDroppedMember.story = {
|
|
|
|
name: 'Not yet migrated, just dropped member',
|
|
|
|
};
|