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

148 lines
3.4 KiB
TypeScript
Raw Normal View History

2022-07-22 00:44:35 +00:00
// Copyright 2020-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2022-07-22 00:44:35 +00:00
import type { Meta, Story } from '@storybook/react';
import * as React from 'react';
2022-07-22 00:44:35 +00:00
import casual from 'casual';
2022-07-22 00:44:35 +00:00
import type { ConversationType } from '../../state/ducks/conversations';
import type { PropsType } from './ContactModal';
import enMessages from '../../../_locales/en/messages.json';
2022-07-22 00:44:35 +00:00
import { ContactModal } from './ContactModal';
import { HasStories } from '../../types/Stories';
2021-11-11 16:23:00 +00:00
import { ThemeType } from '../../types/Util';
2022-07-22 00:44:35 +00:00
import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation';
import { getFakeBadges } from '../../test-both/helpers/getFakeBadge';
import { setupI18n } from '../../util/setupI18n';
const i18n = setupI18n('en', enMessages);
2021-05-07 22:21:10 +00:00
const defaultContact: ConversationType = getDefaultConversation({
2021-01-26 01:01:19 +00:00
about: '👍 Free to chat',
2021-05-07 22:21:10 +00:00
});
2022-07-22 00:44:35 +00:00
const defaultGroup: ConversationType = getDefaultConversation({
areWeAdmin: true,
2022-07-22 00:44:35 +00:00
groupLink: casual.url,
title: casual.title,
type: 'group',
});
2022-07-22 00:44:35 +00:00
export default {
title: 'Components/Conversation/ContactModal',
component: ContactModal,
argTypes: {
i18n: {
defaultValue: i18n,
},
areWeASubscriber: {
defaultValue: false,
},
areWeAdmin: {
defaultValue: false,
},
badges: {
defaultValue: [],
},
contact: {
defaultValue: defaultContact,
},
conversation: {
defaultValue: defaultGroup,
},
hasStories: {
defaultValue: undefined,
},
hideContactModal: { action: true },
isAdmin: {
defaultValue: false,
},
isMember: {
defaultValue: true,
},
removeMemberFromGroup: { action: true },
showConversation: { action: true },
theme: {
defaultValue: ThemeType.light,
},
toggleAdmin: { action: true },
toggleSafetyNumberModal: { action: true },
updateConversationModelSharedGroups: { action: true },
viewUserStories: { action: true },
},
} as Meta;
const Template: Story<PropsType> = args => <ContactModal {...args} />;
export const AsNonAdmin = Template.bind({});
AsNonAdmin.args = {
areWeAdmin: false,
2022-06-07 00:48:02 +00:00
};
AsNonAdmin.story = {
name: 'As non-admin',
};
2022-07-22 00:44:35 +00:00
export const AsAdmin = Template.bind({});
AsAdmin.args = {
areWeAdmin: true,
2022-06-07 00:48:02 +00:00
};
AsAdmin.story = {
name: 'As admin',
};
2022-07-22 00:44:35 +00:00
export const AsAdminWithNoGroupLink = Template.bind({});
AsAdminWithNoGroupLink.args = {
areWeAdmin: true,
conversation: {
...defaultGroup,
groupLink: undefined,
},
2022-06-07 00:48:02 +00:00
};
AsAdminWithNoGroupLink.story = {
name: 'As admin with no group link',
};
2022-07-22 00:44:35 +00:00
export const AsAdminViewingNonMemberOfGroup = Template.bind({});
AsAdminViewingNonMemberOfGroup.args = {
isMember: false,
2022-06-07 00:48:02 +00:00
};
AsAdminViewingNonMemberOfGroup.story = {
name: 'As admin, viewing non-member of group',
};
2022-07-22 00:44:35 +00:00
export const WithoutPhoneNumber = Template.bind({});
WithoutPhoneNumber.args = {
contact: {
...defaultContact,
phoneNumber: undefined,
},
2022-06-07 00:48:02 +00:00
};
WithoutPhoneNumber.story = {
name: 'Without phone number',
};
2022-07-22 00:44:35 +00:00
export const ViewingSelf = Template.bind({});
ViewingSelf.args = {
contact: {
...defaultContact,
isMe: true,
},
2022-06-07 00:48:02 +00:00
};
ViewingSelf.story = {
name: 'Viewing self',
};
2022-07-22 00:44:35 +00:00
export const WithBadges = Template.bind({});
WithBadges.args = {
badges: getFakeBadges(2),
2022-06-07 00:48:02 +00:00
};
WithBadges.story = {
name: 'With badges',
};
2022-07-22 00:44:35 +00:00
export const WithUnreadStories = Template.bind({});
WithUnreadStories.args = {
hasStories: HasStories.Unread,
};
WithUnreadStories.storyName = 'Unread Stories';