2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-10-30 17:52:21 +00:00
|
|
|
import React, { ComponentProps } from 'react';
|
2020-03-26 21:47:35 +00:00
|
|
|
|
|
|
|
import { storiesOf } from '@storybook/react';
|
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
|
|
|
|
import { setup as setupI18n } from '../../../js/modules/i18n';
|
2020-09-14 19:51:27 +00:00
|
|
|
import enMessages from '../../../_locales/en/messages.json';
|
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;
|
2020-10-30 17:52:21 +00:00
|
|
|
props: ComponentProps<typeof ConversationHeader>;
|
2020-03-26 21:47:35 +00:00
|
|
|
}>;
|
|
|
|
};
|
|
|
|
|
2020-10-30 17:52:21 +00:00
|
|
|
const commonProps = {
|
|
|
|
showBackButton: false,
|
2020-11-19 16:37:56 +00:00
|
|
|
outgoingCallButtonStyle: OutgoingCallButtonStyle.Both,
|
2020-10-30 17:52:21 +00:00
|
|
|
markedUnread: false,
|
|
|
|
|
|
|
|
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'),
|
|
|
|
onResetSession: action('onResetSession'),
|
|
|
|
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
|
|
|
|
|
|
|
onShowSafetyNumber: action('onShowSafetyNumber'),
|
|
|
|
onShowAllMedia: action('onShowAllMedia'),
|
2021-01-28 00:18:50 +00:00
|
|
|
onShowContactModal: action('onShowContactModal'),
|
2020-03-26 21:47:35 +00:00
|
|
|
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,
|
2020-03-26 21:47:35 +00:00
|
|
|
color: 'red',
|
|
|
|
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,
|
2020-03-26 21:47:35 +00:00
|
|
|
color: 'blue',
|
|
|
|
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,
|
2020-07-24 01:35:32 +00:00
|
|
|
color: 'blue',
|
|
|
|
isVerified: false,
|
|
|
|
title: 'Joyrey 🔥 Leppey',
|
|
|
|
name: 'Joyrey 🔥 Leppey',
|
|
|
|
phoneNumber: '(202) 555-0002',
|
|
|
|
type: 'direct',
|
2020-03-26 21:47:35 +00:00
|
|
|
id: '2',
|
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,
|
2020-03-26 21:47:35 +00:00
|
|
|
color: 'teal',
|
|
|
|
isVerified: false,
|
|
|
|
phoneNumber: '(202) 555-0003',
|
2020-07-24 01:35:32 +00:00
|
|
|
type: 'direct',
|
2020-03-26 21:47:35 +00:00
|
|
|
id: '3',
|
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',
|
2020-03-26 21:47:35 +00:00
|
|
|
id: '11',
|
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,
|
|
|
|
color: 'deep_orange',
|
|
|
|
phoneNumber: '(202) 555-0004',
|
2020-07-24 01:35:32 +00:00
|
|
|
title: '(202) 555-0004',
|
|
|
|
type: 'direct',
|
2020-03-26 21:47:35 +00:00
|
|
|
id: '4',
|
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,
|
2020-03-26 21:47:35 +00:00
|
|
|
color: 'indigo',
|
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',
|
2020-03-26 21:47:35 +00:00
|
|
|
id: '5',
|
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,
|
|
|
|
color: 'indigo',
|
|
|
|
title: '(202) 555-0005',
|
|
|
|
phoneNumber: '(202) 555-0005',
|
|
|
|
type: 'direct',
|
|
|
|
id: '5',
|
|
|
|
expireTimer: 60,
|
|
|
|
acceptedMessageRequest: true,
|
|
|
|
isVerified: true,
|
|
|
|
},
|
|
|
|
},
|
2020-08-27 19:45:08 +00:00
|
|
|
{
|
|
|
|
title: 'Muting Conversation',
|
|
|
|
props: {
|
2020-10-30 17:52:21 +00:00
|
|
|
...commonProps,
|
2020-08-27 19:45:08 +00:00
|
|
|
color: 'ultramarine',
|
|
|
|
title: '(202) 555-0006',
|
|
|
|
phoneNumber: '(202) 555-0006',
|
|
|
|
type: 'direct',
|
|
|
|
id: '6',
|
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
|
|
|
},
|
|
|
|
},
|
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,
|
2020-03-26 21:47:35 +00:00
|
|
|
color: 'signal-blue',
|
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: '',
|
|
|
|
id: '1',
|
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,
|
2020-03-26 21:47:35 +00:00
|
|
|
color: 'signal-blue',
|
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: '',
|
|
|
|
id: '2',
|
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,
|
|
|
|
color: 'signal-blue',
|
|
|
|
title: 'Typescript support group',
|
|
|
|
name: 'Typescript support group',
|
|
|
|
phoneNumber: '',
|
|
|
|
id: '1',
|
|
|
|
type: 'group',
|
|
|
|
expireTimer: 10,
|
|
|
|
acceptedMessageRequest: true,
|
|
|
|
outgoingCallButtonStyle: OutgoingCallButtonStyle.Join,
|
|
|
|
},
|
|
|
|
},
|
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,
|
2020-03-26 21:47:35 +00:00
|
|
|
color: 'blue',
|
2020-07-24 01:35:32 +00:00
|
|
|
title: '(202) 555-0007',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-0007',
|
|
|
|
id: '7',
|
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,
|
2020-05-27 21:37:06 +00:00
|
|
|
color: 'blue',
|
2020-07-24 01:35:32 +00:00
|
|
|
title: '(202) 555-0007',
|
2020-05-27 21:37:06 +00:00
|
|
|
phoneNumber: '(202) 555-0007',
|
|
|
|
id: '7',
|
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,
|
|
|
|
() =>
|
|
|
|
items.map(({ title: subtitle, props }, i) => {
|
|
|
|
return (
|
|
|
|
<div key={i}>
|
|
|
|
{subtitle ? <h3>{subtitle}</h3> : null}
|
|
|
|
<ConversationHeader {...props} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
{
|
|
|
|
docs: description,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|