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
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { ComponentProps } from 'react';
|
2021-11-02 23:01:13 +00:00
|
|
|
import React, { useContext } from 'react';
|
2020-03-26 21:47:35 +00:00
|
|
|
|
|
|
|
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';
|
2021-11-02 23:01:13 +00:00
|
|
|
import { StorybookThemeContext } from '../../../.storybook/StorybookThemeContext';
|
2020-11-19 16:37:56 +00:00
|
|
|
import {
|
|
|
|
ConversationHeader,
|
|
|
|
OutgoingCallButtonStyle,
|
|
|
|
} from './ConversationHeader';
|
2020-04-06 16:48:58 +00:00
|
|
|
import { gifUrl } from '../../storybook/Fixtures';
|
2020-03-26 21:47:35 +00:00
|
|
|
|
|
|
|
const book = storiesOf('Components/Conversation/ConversationHeader', module);
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
type ConversationHeaderStory = {
|
|
|
|
title: string;
|
|
|
|
description: string;
|
|
|
|
items: Array<{
|
|
|
|
title: string;
|
2021-11-02 23:01:13 +00:00
|
|
|
props: Omit<ComponentProps<typeof ConversationHeader>, 'theme'>;
|
2020-03-26 21:47:35 +00:00
|
|
|
}>;
|
|
|
|
};
|
|
|
|
|
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,
|
2020-11-19 16:37:56 +00:00
|
|
|
outgoingCallButtonStyle: OutgoingCallButtonStyle.Both,
|
2020-10-30 17:52:21 +00:00
|
|
|
|
|
|
|
i18n,
|
|
|
|
|
2021-01-29 21:19:24 +00:00
|
|
|
onShowConversationDetails: action('onShowConversationDetails'),
|
2020-03-26 21:47:35 +00:00
|
|
|
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'
|
|
|
|
),
|
2020-03-26 21:47:35 +00:00
|
|
|
|
|
|
|
onShowAllMedia: action('onShowAllMedia'),
|
|
|
|
onShowGroupMembers: action('onShowGroupMembers'),
|
|
|
|
onGoBack: action('onGoBack'),
|
|
|
|
|
|
|
|
onArchive: action('onArchive'),
|
2020-10-28 22:54:32 +00:00
|
|
|
onMarkUnread: action('onMarkUnread'),
|
2020-03-26 21:47:35 +00:00
|
|
|
onMoveToInbox: action('onMoveToInbox'),
|
2020-10-02 18:30:43 +00:00
|
|
|
onSetPin: action('onSetPin'),
|
2020-03-26 21:47:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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(),
|
2020-03-26 21:47:35 +00:00
|
|
|
isVerified: true,
|
2020-04-06 16:48:58 +00:00
|
|
|
avatarPath: gifUrl,
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Someone 🔥 Somewhere',
|
2020-03-26 21:47:35 +00:00
|
|
|
name: 'Someone 🔥 Somewhere',
|
|
|
|
phoneNumber: '(202) 555-0001',
|
2020-07-24 01:35:32 +00:00
|
|
|
type: 'direct',
|
2020-03-26 21:47:35 +00:00
|
|
|
id: '1',
|
|
|
|
profileName: '🔥Flames🔥',
|
2020-10-28 21:54:33 +00:00
|
|
|
acceptedMessageRequest: true,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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(),
|
2020-03-26 21:47:35 +00:00
|
|
|
isVerified: false,
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Someone 🔥 Somewhere',
|
2020-03-26 21:47:35 +00:00
|
|
|
name: 'Someone 🔥 Somewhere',
|
|
|
|
phoneNumber: '(202) 555-0002',
|
2020-07-24 01:35:32 +00:00
|
|
|
type: 'direct',
|
|
|
|
id: '2',
|
2020-10-28 21:54:33 +00:00
|
|
|
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',
|
2020-10-28 21:54:33 +00:00
|
|
|
acceptedMessageRequest: true,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Profile, no name',
|
|
|
|
props: {
|
2020-10-30 17:52:21 +00:00
|
|
|
...commonProps,
|
2021-08-06 00:17:05 +00:00
|
|
|
color: getRandomColor(),
|
2020-03-26 21:47:35 +00:00
|
|
|
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🔥',
|
2020-03-26 21:47:35 +00:00
|
|
|
profileName: '🔥Flames🔥',
|
2020-10-28 21:54:33 +00:00
|
|
|
acceptedMessageRequest: true,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-0011',
|
2020-07-24 01:35:32 +00:00
|
|
|
type: 'direct',
|
2021-06-01 20:45:43 +00:00
|
|
|
id: '5',
|
2020-10-28 21:54:33 +00:00
|
|
|
acceptedMessageRequest: true,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'With back button',
|
|
|
|
props: {
|
2020-10-30 17:52:21 +00:00
|
|
|
...commonProps,
|
2020-03-26 21:47:35 +00:00
|
|
|
showBackButton: true,
|
2021-08-06 00:17:05 +00:00
|
|
|
color: getRandomColor(),
|
2020-03-26 21:47:35 +00:00
|
|
|
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',
|
2020-10-28 21:54:33 +00:00
|
|
|
acceptedMessageRequest: true,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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',
|
2020-03-26 21:47:35 +00:00
|
|
|
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,
|
2020-10-28 21:54:33 +00:00
|
|
|
acceptedMessageRequest: true,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
|
|
|
},
|
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',
|
2020-10-28 21:54:33 +00:00
|
|
|
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
|
|
|
},
|
|
|
|
},
|
2021-05-25 22:30:57 +00:00
|
|
|
{
|
|
|
|
title: 'SMS-only conversation',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
2021-08-06 00:17:05 +00:00
|
|
|
color: getRandomColor(),
|
2021-05-25 22:30:57 +00:00
|
|
|
title: '(202) 555-0006',
|
|
|
|
phoneNumber: '(202) 555-0006',
|
|
|
|
type: 'direct',
|
2021-06-01 20:45:43 +00:00
|
|
|
id: '10',
|
2021-05-25 22:30:57 +00:00
|
|
|
acceptedMessageRequest: true,
|
|
|
|
isSMSOnly: true,
|
|
|
|
},
|
|
|
|
},
|
2020-03-26 21:47:35 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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',
|
2020-03-26 21:47:35 +00:00
|
|
|
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,
|
2020-10-28 21:54:33 +00:00
|
|
|
acceptedMessageRequest: true,
|
2020-11-19 16:37:56 +00:00
|
|
|
outgoingCallButtonStyle: OutgoingCallButtonStyle.JustVideo,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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',
|
2020-03-26 21:47:35 +00:00
|
|
|
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,
|
2020-10-28 21:54:33 +00:00
|
|
|
acceptedMessageRequest: true,
|
2020-11-19 16:37:56 +00:00
|
|
|
outgoingCallButtonStyle: OutgoingCallButtonStyle.JustVideo,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
|
|
|
},
|
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,
|
|
|
|
},
|
|
|
|
},
|
2020-03-26 21:47:35 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-0007',
|
2021-06-01 20:45:43 +00:00
|
|
|
id: '15',
|
2020-07-24 01:35:32 +00:00
|
|
|
type: 'direct',
|
2020-03-26 21:47:35 +00:00
|
|
|
isMe: true,
|
2020-10-28 21:54:33 +00:00
|
|
|
acceptedMessageRequest: true,
|
2020-11-19 16:37:56 +00:00
|
|
|
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,
|
2020-10-28 21:54:33 +00:00
|
|
|
acceptedMessageRequest: false,
|
2020-11-19 16:37:56 +00:00
|
|
|
outgoingCallButtonStyle: OutgoingCallButtonStyle.None,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
stories.forEach(({ title, description, items }) =>
|
|
|
|
book.add(
|
|
|
|
title,
|
2021-11-02 23:01:13 +00:00
|
|
|
() => {
|
|
|
|
const theme = useContext(StorybookThemeContext);
|
|
|
|
|
|
|
|
return items.map(({ title: subtitle, props }, i) => {
|
2020-03-26 21:47:35 +00:00
|
|
|
return (
|
|
|
|
<div key={i}>
|
|
|
|
{subtitle ? <h3>{subtitle}</h3> : null}
|
2021-11-02 23:01:13 +00:00
|
|
|
<ConversationHeader {...props} theme={theme} />
|
2020-03-26 21:47:35 +00:00
|
|
|
</div>
|
|
|
|
);
|
2021-11-02 23:01:13 +00:00
|
|
|
});
|
|
|
|
},
|
2020-03-26 21:47:35 +00:00
|
|
|
{
|
|
|
|
docs: description,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|