2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2020 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 { 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';
|
2022-11-16 20:18:02 +00:00
|
|
|
import { DurationInSeconds } from '../../util/durations';
|
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
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export default {
|
|
|
|
title: 'Components/Conversation/ConversationHeader',
|
|
|
|
};
|
|
|
|
|
2020-03-26 21:47:35 +00:00
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
type ItemsType = Array<{
|
2020-03-26 21:47:35 +00:00
|
|
|
title: string;
|
2022-06-07 00:48:02 +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(),
|
|
|
|
|
2023-06-29 18:40:00 +00:00
|
|
|
cannotLeaveBecauseYouAreLastAdmin: false,
|
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,
|
|
|
|
|
2022-12-05 22:56:23 +00:00
|
|
|
setDisappearingMessages: action('setDisappearingMessages'),
|
|
|
|
destroyMessages: action('destroyMessages'),
|
2023-06-29 18:40:00 +00:00
|
|
|
leaveGroup: action('leaveGroup'),
|
2020-06-04 18:16:19 +00:00
|
|
|
onOutgoingAudioCallInConversation: action(
|
|
|
|
'onOutgoingAudioCallInConversation'
|
|
|
|
),
|
|
|
|
onOutgoingVideoCallInConversation: action(
|
|
|
|
'onOutgoingVideoCallInConversation'
|
|
|
|
),
|
2020-03-26 21:47:35 +00:00
|
|
|
|
|
|
|
onArchive: action('onArchive'),
|
2020-10-28 22:54:32 +00:00
|
|
|
onMarkUnread: action('onMarkUnread'),
|
2023-03-20 22:23:53 +00:00
|
|
|
toggleSelectMode: action('toggleSelectMode'),
|
2020-03-26 21:47:35 +00:00
|
|
|
onMoveToInbox: action('onMoveToInbox'),
|
2022-12-15 01:10:09 +00:00
|
|
|
pushPanelForConversation: action('pushPanelForConversation'),
|
2022-12-21 03:25:10 +00:00
|
|
|
popPanelForConversation: action('popPanelForConversation'),
|
|
|
|
searchInConversation: action('searchInConversation'),
|
2022-12-06 17:31:44 +00:00
|
|
|
setMuteExpiration: action('onSetMuteNotifications'),
|
2022-12-07 01:00:02 +00:00
|
|
|
setPinned: action('setPinned'),
|
2022-07-22 00:44:35 +00:00
|
|
|
viewUserStories: action('viewUserStories'),
|
2020-03-26 21:47:35 +00:00
|
|
|
};
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function PrivateConvo(): JSX.Element {
|
2022-06-07 00:48:02 +00:00
|
|
|
const items: ItemsType = [
|
|
|
|
{
|
|
|
|
title: 'With name and profile, verified',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
color: getRandomColor(),
|
|
|
|
isVerified: true,
|
|
|
|
avatarPath: gifUrl,
|
|
|
|
title: 'Someone 🔥 Somewhere',
|
|
|
|
name: 'Someone 🔥 Somewhere',
|
|
|
|
phoneNumber: '(202) 555-0001',
|
|
|
|
type: 'direct',
|
|
|
|
id: '1',
|
|
|
|
profileName: '🔥Flames🔥',
|
|
|
|
acceptedMessageRequest: true,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'With name, not verified, no avatar',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
color: getRandomColor(),
|
|
|
|
isVerified: false,
|
|
|
|
title: 'Someone 🔥 Somewhere',
|
|
|
|
name: 'Someone 🔥 Somewhere',
|
|
|
|
phoneNumber: '(202) 555-0002',
|
|
|
|
type: 'direct',
|
|
|
|
id: '2',
|
|
|
|
acceptedMessageRequest: true,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'With name, not verified, descenders',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
color: getRandomColor(),
|
|
|
|
isVerified: false,
|
|
|
|
title: 'Joyrey 🔥 Leppey',
|
|
|
|
name: 'Joyrey 🔥 Leppey',
|
|
|
|
phoneNumber: '(202) 555-0002',
|
|
|
|
type: 'direct',
|
|
|
|
id: '3',
|
|
|
|
acceptedMessageRequest: true,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Profile, no name',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
color: getRandomColor(),
|
|
|
|
isVerified: false,
|
|
|
|
phoneNumber: '(202) 555-0003',
|
|
|
|
type: 'direct',
|
|
|
|
id: '4',
|
|
|
|
title: '🔥Flames🔥',
|
|
|
|
profileName: '🔥Flames🔥',
|
|
|
|
acceptedMessageRequest: true,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'No name, no profile, no color',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
title: '(202) 555-0011',
|
|
|
|
phoneNumber: '(202) 555-0011',
|
|
|
|
type: 'direct',
|
|
|
|
id: '5',
|
|
|
|
acceptedMessageRequest: true,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'With back button',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
showBackButton: true,
|
|
|
|
color: getRandomColor(),
|
|
|
|
phoneNumber: '(202) 555-0004',
|
|
|
|
title: '(202) 555-0004',
|
|
|
|
type: 'direct',
|
|
|
|
id: '6',
|
|
|
|
acceptedMessageRequest: true,
|
2021-03-01 20:08:37 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Disappearing messages set',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
color: getRandomColor(),
|
|
|
|
title: '(202) 555-0005',
|
|
|
|
phoneNumber: '(202) 555-0005',
|
|
|
|
type: 'direct',
|
|
|
|
id: '7',
|
2022-11-16 20:18:02 +00:00
|
|
|
expireTimer: DurationInSeconds.fromSeconds(10),
|
2022-06-07 00:48:02 +00:00
|
|
|
acceptedMessageRequest: true,
|
2020-08-27 19:45:08 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Disappearing messages + verified',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
color: getRandomColor(),
|
|
|
|
title: '(202) 555-0005',
|
|
|
|
phoneNumber: '(202) 555-0005',
|
|
|
|
type: 'direct',
|
|
|
|
id: '8',
|
2022-11-16 20:18:02 +00:00
|
|
|
expireTimer: DurationInSeconds.fromSeconds(300),
|
2022-06-07 00:48:02 +00:00
|
|
|
acceptedMessageRequest: true,
|
|
|
|
isVerified: true,
|
|
|
|
canChangeTimer: true,
|
2021-05-25 22:30:57 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Muting Conversation',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
color: getRandomColor(),
|
|
|
|
title: '(202) 555-0006',
|
|
|
|
phoneNumber: '(202) 555-0006',
|
|
|
|
type: 'direct',
|
|
|
|
id: '9',
|
|
|
|
acceptedMessageRequest: true,
|
|
|
|
muteExpiresAt: new Date('3000-10-18T11:11:11Z').valueOf(),
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'SMS-only conversation',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
color: getRandomColor(),
|
|
|
|
title: '(202) 555-0006',
|
|
|
|
phoneNumber: '(202) 555-0006',
|
|
|
|
type: 'direct',
|
|
|
|
id: '10',
|
|
|
|
acceptedMessageRequest: true,
|
|
|
|
isSMSOnly: true,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const theme = useContext(StorybookThemeContext);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{items.map(({ title: subtitle, props }, i) => {
|
|
|
|
return (
|
|
|
|
<div key={i}>
|
|
|
|
{subtitle ? <h3>{subtitle}</h3> : null}
|
|
|
|
<ConversationHeader {...props} theme={theme} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
|
|
|
PrivateConvo.story = {
|
|
|
|
name: '1:1 conversation',
|
|
|
|
};
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function Group(): JSX.Element {
|
2022-06-07 00:48:02 +00:00
|
|
|
const items: ItemsType = [
|
|
|
|
{
|
|
|
|
title: 'Basic',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
color: getRandomColor(),
|
|
|
|
title: 'Typescript support group',
|
|
|
|
name: 'Typescript support group',
|
|
|
|
phoneNumber: '',
|
|
|
|
id: '11',
|
|
|
|
type: 'group',
|
2022-11-16 20:18:02 +00:00
|
|
|
expireTimer: DurationInSeconds.fromSeconds(10),
|
2022-06-07 00:48:02 +00:00
|
|
|
acceptedMessageRequest: true,
|
|
|
|
outgoingCallButtonStyle: OutgoingCallButtonStyle.JustVideo,
|
2020-11-20 17:19:28 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'In a group you left - no disappearing messages',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
color: getRandomColor(),
|
|
|
|
title: 'Typescript support group',
|
|
|
|
name: 'Typescript support group',
|
|
|
|
phoneNumber: '',
|
|
|
|
id: '12',
|
|
|
|
type: 'group',
|
|
|
|
left: true,
|
2022-11-16 20:18:02 +00:00
|
|
|
expireTimer: DurationInSeconds.fromSeconds(10),
|
2022-06-07 00:48:02 +00:00
|
|
|
acceptedMessageRequest: true,
|
|
|
|
outgoingCallButtonStyle: OutgoingCallButtonStyle.JustVideo,
|
2021-04-09 16:19:38 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'In a group with an active group call',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
color: getRandomColor(),
|
|
|
|
title: 'Typescript support group',
|
|
|
|
name: 'Typescript support group',
|
|
|
|
phoneNumber: '',
|
|
|
|
id: '13',
|
|
|
|
type: 'group',
|
2022-11-16 20:18:02 +00:00
|
|
|
expireTimer: DurationInSeconds.fromSeconds(10),
|
2022-06-07 00:48:02 +00:00
|
|
|
acceptedMessageRequest: true,
|
|
|
|
outgoingCallButtonStyle: OutgoingCallButtonStyle.Join,
|
2020-05-27 21:37:06 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'In a forever muted group',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
color: getRandomColor(),
|
|
|
|
title: 'Way too many messages',
|
|
|
|
name: 'Way too many messages',
|
|
|
|
phoneNumber: '',
|
|
|
|
id: '14',
|
|
|
|
type: 'group',
|
2022-11-16 20:18:02 +00:00
|
|
|
expireTimer: DurationInSeconds.fromSeconds(10),
|
2022-06-07 00:48:02 +00:00
|
|
|
acceptedMessageRequest: true,
|
|
|
|
outgoingCallButtonStyle: OutgoingCallButtonStyle.JustVideo,
|
|
|
|
muteExpiresAt: Infinity,
|
2020-03-26 21:47:35 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
},
|
|
|
|
];
|
2020-03-26 21:47:35 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
const theme = useContext(StorybookThemeContext);
|
2021-11-02 23:01:13 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
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>
|
|
|
|
);
|
2022-06-07 00:48:02 +00:00
|
|
|
})}
|
|
|
|
</>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
|
|
|
Group.story = {
|
|
|
|
name: 'In a group',
|
|
|
|
};
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
function NoteToSelf() {
|
2022-06-07 00:48:02 +00:00
|
|
|
const items: ItemsType = [
|
|
|
|
{
|
|
|
|
title: 'In chat with yourself',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
color: getRandomColor(),
|
|
|
|
title: '(202) 555-0007',
|
|
|
|
phoneNumber: '(202) 555-0007',
|
|
|
|
id: '15',
|
|
|
|
type: 'direct',
|
|
|
|
isMe: true,
|
|
|
|
acceptedMessageRequest: true,
|
|
|
|
outgoingCallButtonStyle: OutgoingCallButtonStyle.None,
|
|
|
|
},
|
2021-11-02 23:01:13 +00:00
|
|
|
},
|
2022-06-07 00:48:02 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
const theme = useContext(StorybookThemeContext);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{items.map(({ title: subtitle, props }, i) => {
|
|
|
|
return (
|
|
|
|
<div key={i}>
|
|
|
|
{subtitle ? <h3>{subtitle}</h3> : null}
|
|
|
|
<ConversationHeader {...props} theme={theme} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
|
|
|
NoteToSelf.story = {
|
|
|
|
name: 'Note to Self',
|
|
|
|
};
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
function Unaccepted() {
|
2022-06-07 00:48:02 +00:00
|
|
|
const items: ItemsType = [
|
2020-03-26 21:47:35 +00:00
|
|
|
{
|
2022-06-07 00:48:02 +00:00
|
|
|
title: '1:1 conversation',
|
|
|
|
props: {
|
|
|
|
...commonProps,
|
|
|
|
color: getRandomColor(),
|
|
|
|
title: '(202) 555-0007',
|
|
|
|
phoneNumber: '(202) 555-0007',
|
|
|
|
id: '16',
|
|
|
|
type: 'direct',
|
|
|
|
isMe: false,
|
|
|
|
acceptedMessageRequest: false,
|
|
|
|
outgoingCallButtonStyle: OutgoingCallButtonStyle.None,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const theme = useContext(StorybookThemeContext);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{items.map(({ title: subtitle, props }, i) => {
|
|
|
|
return (
|
|
|
|
<div key={i}>
|
|
|
|
{subtitle ? <h3>{subtitle}</h3> : null}
|
|
|
|
<ConversationHeader {...props} theme={theme} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
|
|
|
Unaccepted.story = {
|
|
|
|
name: 'Unaccepted',
|
|
|
|
};
|