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

333 lines
9 KiB
TypeScript
Raw Normal View History

2021-05-07 22:21:10 +00:00
// Copyright 2020-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
2020-10-30 17:52:21 +00:00
import React, { ComponentProps } from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
2021-05-07 22:21:10 +00:00
import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation';
2021-08-06 00:17:05 +00:00
import { getRandomColor } from '../../test-both/helpers/getRandomColor';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../../util/setupI18n';
2020-09-14 19:51:27 +00:00
import enMessages from '../../../_locales/en/messages.json';
import {
ConversationHeader,
OutgoingCallButtonStyle,
} from './ConversationHeader';
2020-04-06 16:48:58 +00:00
import { gifUrl } from '../../storybook/Fixtures';
const book = storiesOf('Components/Conversation/ConversationHeader', module);
const i18n = setupI18n('en', enMessages);
type ConversationHeaderStory = {
title: string;
description: string;
items: Array<{
title: string;
2020-10-30 17:52:21 +00:00
props: ComponentProps<typeof ConversationHeader>;
}>;
};
2020-10-30 17:52:21 +00:00
const commonProps = {
2021-05-07 22:21:10 +00:00
...getDefaultConversation(),
2020-10-30 17:52:21 +00:00
showBackButton: false,
outgoingCallButtonStyle: OutgoingCallButtonStyle.Both,
2020-10-30 17:52:21 +00:00
i18n,
onShowConversationDetails: action('onShowConversationDetails'),
onSetDisappearingMessages: action('onSetDisappearingMessages'),
onDeleteMessages: action('onDeleteMessages'),
onSearchInConversation: action('onSearchInConversation'),
2020-08-27 19:45:08 +00:00
onSetMuteNotifications: action('onSetMuteNotifications'),
2020-06-04 18:16:19 +00:00
onOutgoingAudioCallInConversation: action(
'onOutgoingAudioCallInConversation'
),
onOutgoingVideoCallInConversation: action(
'onOutgoingVideoCallInConversation'
),
onShowAllMedia: action('onShowAllMedia'),
onShowGroupMembers: action('onShowGroupMembers'),
onGoBack: action('onGoBack'),
onArchive: action('onArchive'),
onMarkUnread: action('onMarkUnread'),
onMoveToInbox: action('onMoveToInbox'),
2020-10-02 18:30:43 +00:00
onSetPin: action('onSetPin'),
};
const stories: Array<ConversationHeaderStory> = [
{
title: '1:1 conversation',
description:
"Note the five items in menu, and the second-level menu with disappearing messages options. Disappearing message set to 'off'.",
items: [
{
title: 'With name and profile, verified',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
isVerified: true,
2020-04-06 16:48:58 +00:00
avatarPath: gifUrl,
2020-07-24 01:35:32 +00:00
title: 'Someone 🔥 Somewhere',
name: 'Someone 🔥 Somewhere',
phoneNumber: '(202) 555-0001',
2020-07-24 01:35:32 +00:00
type: 'direct',
id: '1',
profileName: '🔥Flames🔥',
acceptedMessageRequest: true,
},
},
{
title: 'With name, not verified, no avatar',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
isVerified: false,
2020-07-24 01:35:32 +00:00
title: 'Someone 🔥 Somewhere',
name: 'Someone 🔥 Somewhere',
phoneNumber: '(202) 555-0002',
2020-07-24 01:35:32 +00:00
type: 'direct',
id: '2',
acceptedMessageRequest: true,
2020-07-24 01:35:32 +00:00
},
},
{
title: 'With name, not verified, descenders',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
2020-07-24 01:35:32 +00:00
isVerified: false,
title: 'Joyrey 🔥 Leppey',
name: 'Joyrey 🔥 Leppey',
phoneNumber: '(202) 555-0002',
type: 'direct',
2021-06-01 20:45:43 +00:00
id: '3',
acceptedMessageRequest: true,
},
},
{
title: 'Profile, no name',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
isVerified: false,
phoneNumber: '(202) 555-0003',
2020-07-24 01:35:32 +00:00
type: 'direct',
2021-06-01 20:45:43 +00:00
id: '4',
2020-07-24 01:35:32 +00:00
title: '🔥Flames🔥',
profileName: '🔥Flames🔥',
acceptedMessageRequest: true,
},
},
{
title: 'No name, no profile, no color',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2020-07-24 01:35:32 +00:00
title: '(202) 555-0011',
phoneNumber: '(202) 555-0011',
2020-07-24 01:35:32 +00:00
type: 'direct',
2021-06-01 20:45:43 +00:00
id: '5',
acceptedMessageRequest: true,
},
},
{
title: 'With back button',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
showBackButton: true,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
phoneNumber: '(202) 555-0004',
2020-07-24 01:35:32 +00:00
title: '(202) 555-0004',
type: 'direct',
2021-06-01 20:45:43 +00:00
id: '6',
acceptedMessageRequest: true,
},
},
{
title: 'Disappearing messages set',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
2020-07-24 01:35:32 +00:00
title: '(202) 555-0005',
phoneNumber: '(202) 555-0005',
2020-07-24 01:35:32 +00:00
type: 'direct',
2021-06-01 20:45:43 +00:00
id: '7',
2020-10-30 17:52:21 +00:00
expireTimer: 10,
acceptedMessageRequest: true,
},
},
2021-03-01 20:08:37 +00:00
{
title: 'Disappearing messages + verified',
props: {
...commonProps,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
2021-03-01 20:08:37 +00:00
title: '(202) 555-0005',
phoneNumber: '(202) 555-0005',
type: 'direct',
2021-06-01 20:45:43 +00:00
id: '8',
expireTimer: 300,
2021-03-01 20:08:37 +00:00
acceptedMessageRequest: true,
isVerified: true,
2021-06-01 20:45:43 +00:00
canChangeTimer: true,
2021-03-01 20:08:37 +00:00
},
},
2020-08-27 19:45:08 +00:00
{
title: 'Muting Conversation',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
2020-08-27 19:45:08 +00:00
title: '(202) 555-0006',
phoneNumber: '(202) 555-0006',
type: 'direct',
2021-06-01 20:45:43 +00:00
id: '9',
acceptedMessageRequest: true,
2020-10-30 17:52:21 +00:00
muteExpiresAt: new Date('3000-10-18T11:11:11Z').valueOf(),
2020-08-27 19:45:08 +00:00
},
},
{
title: 'SMS-only conversation',
props: {
...commonProps,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
title: '(202) 555-0006',
phoneNumber: '(202) 555-0006',
type: 'direct',
2021-06-01 20:45:43 +00:00
id: '10',
acceptedMessageRequest: true,
isSMSOnly: true,
},
},
],
},
{
title: 'In a group',
description:
"Note that the menu should includes 'Show Members' instead of 'Show Safety Number'",
items: [
{
title: 'Basic',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
2020-07-24 01:35:32 +00:00
title: 'Typescript support group',
name: 'Typescript support group',
phoneNumber: '',
2021-06-01 20:45:43 +00:00
id: '11',
2020-07-24 01:35:32 +00:00
type: 'group',
2020-10-30 17:52:21 +00:00
expireTimer: 10,
acceptedMessageRequest: true,
outgoingCallButtonStyle: OutgoingCallButtonStyle.JustVideo,
},
},
{
title: 'In a group you left - no disappearing messages',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
2020-07-24 01:35:32 +00:00
title: 'Typescript support group',
name: 'Typescript support group',
phoneNumber: '',
2021-06-01 20:45:43 +00:00
id: '12',
2020-07-24 01:35:32 +00:00
type: 'group',
2020-10-30 17:52:21 +00:00
left: true,
expireTimer: 10,
acceptedMessageRequest: true,
outgoingCallButtonStyle: OutgoingCallButtonStyle.JustVideo,
},
},
2020-11-20 17:19:28 +00:00
{
title: 'In a group with an active group call',
props: {
...commonProps,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
2020-11-20 17:19:28 +00:00
title: 'Typescript support group',
name: 'Typescript support group',
phoneNumber: '',
2021-06-01 20:45:43 +00:00
id: '13',
2020-11-20 17:19:28 +00:00
type: 'group',
expireTimer: 10,
acceptedMessageRequest: true,
outgoingCallButtonStyle: OutgoingCallButtonStyle.Join,
},
},
2021-04-09 16:19:38 +00:00
{
title: 'In a forever muted group',
props: {
...commonProps,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
2021-04-09 16:19:38 +00:00
title: 'Way too many messages',
name: 'Way too many messages',
phoneNumber: '',
2021-06-01 20:45:43 +00:00
id: '14',
2021-04-09 16:19:38 +00:00
type: 'group',
expireTimer: 10,
acceptedMessageRequest: true,
outgoingCallButtonStyle: OutgoingCallButtonStyle.JustVideo,
muteExpiresAt: Infinity,
},
},
],
},
{
title: 'Note to Self',
description: 'No safety number entry.',
items: [
{
title: 'In chat with yourself',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
2020-07-24 01:35:32 +00:00
title: '(202) 555-0007',
phoneNumber: '(202) 555-0007',
2021-06-01 20:45:43 +00:00
id: '15',
2020-07-24 01:35:32 +00:00
type: 'direct',
isMe: true,
acceptedMessageRequest: true,
outgoingCallButtonStyle: OutgoingCallButtonStyle.None,
2020-05-27 21:37:06 +00:00
},
},
],
},
{
title: 'Unaccepted',
description: 'No safety number entry.',
items: [
{
title: '1:1 conversation',
props: {
2020-10-30 17:52:21 +00:00
...commonProps,
2021-08-06 00:17:05 +00:00
color: getRandomColor(),
2020-07-24 01:35:32 +00:00
title: '(202) 555-0007',
2020-05-27 21:37:06 +00:00
phoneNumber: '(202) 555-0007',
2021-06-01 20:45:43 +00:00
id: '16',
2020-07-24 01:35:32 +00:00
type: 'direct',
2020-05-27 21:37:06 +00:00
isMe: false,
acceptedMessageRequest: false,
outgoingCallButtonStyle: OutgoingCallButtonStyle.None,
},
},
],
},
];
stories.forEach(({ title, description, items }) =>
book.add(
title,
() =>
items.map(({ title: subtitle, props }, i) => {
return (
<div key={i}>
{subtitle ? <h3>{subtitle}</h3> : null}
<ConversationHeader {...props} />
</div>
);
}),
{
docs: description,
}
)
);