2022-01-12 17:35:47 +00:00
|
|
|
// Copyright 2020-2022 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-08-21 16:09:39 +00:00
|
|
|
import * as React from 'react';
|
|
|
|
|
|
|
|
import { action } from '@storybook/addon-actions';
|
2021-05-06 00:09:29 +00:00
|
|
|
import { select } from '@storybook/addon-knobs';
|
2020-08-21 16:09:39 +00:00
|
|
|
import { storiesOf } from '@storybook/react';
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { PropsType } from './LeftPane';
|
|
|
|
import { LeftPane, LeftPaneMode } from './LeftPane';
|
2021-05-06 00:09:29 +00:00
|
|
|
import { CaptchaDialog } from './CaptchaDialog';
|
2022-01-11 20:02:46 +00:00
|
|
|
import { CrashReportDialog } from './CrashReportDialog';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { ConversationType } from '../state/ducks/conversations';
|
2021-02-23 20:34:28 +00:00
|
|
|
import { MessageSearchResult } from './conversationList/MessageSearchResult';
|
2021-09-18 00:30:08 +00:00
|
|
|
import { setupI18n } from '../util/setupI18n';
|
2020-08-21 16:09:39 +00:00
|
|
|
import enMessages from '../../_locales/en/messages.json';
|
2021-11-17 21:11:21 +00:00
|
|
|
import { ThemeType } from '../types/Util';
|
2021-05-07 22:21:10 +00:00
|
|
|
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation';
|
2021-11-02 23:01:13 +00:00
|
|
|
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext';
|
2022-04-05 00:38:22 +00:00
|
|
|
import {
|
|
|
|
makeFakeLookupConversationWithoutUuid,
|
|
|
|
useUuidFetchState,
|
|
|
|
} from '../test-both/helpers/fakeLookupConversationWithoutUuid';
|
2020-09-12 00:46:52 +00:00
|
|
|
|
2020-08-21 16:09:39 +00:00
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
const story = storiesOf('Components/LeftPane', module);
|
|
|
|
|
2021-05-07 22:21:10 +00:00
|
|
|
const defaultConversations: Array<ConversationType> = [
|
|
|
|
getDefaultConversation({
|
2020-08-21 16:09:39 +00:00
|
|
|
id: 'fred-convo',
|
|
|
|
title: 'Fred Willard',
|
2021-05-07 22:21:10 +00:00
|
|
|
}),
|
|
|
|
getDefaultConversation({
|
2020-08-21 16:09:39 +00:00
|
|
|
id: 'marc-convo',
|
|
|
|
isSelected: true,
|
|
|
|
title: 'Marc Barraca',
|
2021-05-07 22:21:10 +00:00
|
|
|
}),
|
2020-08-21 16:09:39 +00:00
|
|
|
];
|
|
|
|
|
2022-01-27 22:12:26 +00:00
|
|
|
const defaultSearchProps = {
|
|
|
|
searchConversation: undefined,
|
|
|
|
searchDisabled: false,
|
|
|
|
searchTerm: 'hello',
|
|
|
|
startSearchCounter: 0,
|
|
|
|
};
|
|
|
|
|
2021-05-07 22:21:10 +00:00
|
|
|
const defaultGroups: Array<ConversationType> = [
|
|
|
|
getDefaultConversation({
|
2021-04-20 23:16:49 +00:00
|
|
|
id: 'biking-group',
|
|
|
|
title: 'Mtn Biking Arizona 🚵☀️⛰',
|
|
|
|
type: 'group',
|
2021-05-07 22:21:10 +00:00
|
|
|
sharedGroupNames: [],
|
|
|
|
}),
|
|
|
|
getDefaultConversation({
|
2021-04-20 23:16:49 +00:00
|
|
|
id: 'dance-group',
|
|
|
|
title: 'Are we dancers? 💃',
|
|
|
|
type: 'group',
|
2021-05-07 22:21:10 +00:00
|
|
|
sharedGroupNames: [],
|
|
|
|
}),
|
2021-04-20 23:16:49 +00:00
|
|
|
];
|
|
|
|
|
2021-05-07 22:21:10 +00:00
|
|
|
const defaultArchivedConversations: Array<ConversationType> = [
|
|
|
|
getDefaultConversation({
|
2020-08-21 16:09:39 +00:00
|
|
|
id: 'michelle-archive-convo',
|
|
|
|
title: 'Michelle Mercure',
|
2021-05-07 22:21:10 +00:00
|
|
|
isArchived: true,
|
|
|
|
}),
|
2020-08-21 16:09:39 +00:00
|
|
|
];
|
|
|
|
|
2021-05-07 22:21:10 +00:00
|
|
|
const pinnedConversations: Array<ConversationType> = [
|
|
|
|
getDefaultConversation({
|
2020-09-29 22:07:03 +00:00
|
|
|
id: 'philly-convo',
|
|
|
|
isPinned: true,
|
|
|
|
title: 'Philip Glass',
|
2021-05-07 22:21:10 +00:00
|
|
|
}),
|
|
|
|
getDefaultConversation({
|
2020-09-29 22:07:03 +00:00
|
|
|
id: 'robbo-convo',
|
|
|
|
isPinned: true,
|
|
|
|
title: 'Robert Moog',
|
2021-05-07 22:21:10 +00:00
|
|
|
}),
|
2020-09-29 22:07:03 +00:00
|
|
|
];
|
|
|
|
|
2021-02-23 20:34:28 +00:00
|
|
|
const defaultModeSpecificProps = {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-02-23 20:34:28 +00:00
|
|
|
mode: LeftPaneMode.Inbox as const,
|
|
|
|
pinnedConversations,
|
|
|
|
conversations: defaultConversations,
|
|
|
|
archivedConversations: defaultArchivedConversations,
|
2021-10-12 23:59:08 +00:00
|
|
|
isAboutToSearchInAConversation: false,
|
2021-02-23 20:34:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const emptySearchResultsGroup = { isLoading: false, results: [] };
|
|
|
|
|
2022-04-05 00:38:22 +00:00
|
|
|
const useProps = (overrideProps: Partial<PropsType> = {}): PropsType => {
|
|
|
|
let modeSpecificProps =
|
|
|
|
overrideProps.modeSpecificProps ?? defaultModeSpecificProps;
|
|
|
|
|
|
|
|
const [uuidFetchState, setIsFetchingUUID] = useUuidFetchState(
|
|
|
|
'uuidFetchState' in modeSpecificProps
|
|
|
|
? modeSpecificProps.uuidFetchState
|
|
|
|
: {}
|
|
|
|
);
|
|
|
|
|
|
|
|
if ('uuidFetchState' in modeSpecificProps) {
|
|
|
|
modeSpecificProps = {
|
|
|
|
...modeSpecificProps,
|
|
|
|
uuidFetchState,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
clearConversationSearch: action('clearConversationSearch'),
|
|
|
|
clearGroupCreationError: action('clearGroupCreationError'),
|
|
|
|
clearSearch: action('clearSearch'),
|
|
|
|
closeMaximumGroupSizeModal: action('closeMaximumGroupSizeModal'),
|
|
|
|
closeRecommendedGroupSizeModal: action('closeRecommendedGroupSizeModal'),
|
|
|
|
composeDeleteAvatarFromDisk: action('composeDeleteAvatarFromDisk'),
|
|
|
|
composeReplaceAvatar: action('composeReplaceAvatar'),
|
|
|
|
composeSaveAvatarToDisk: action('composeSaveAvatarToDisk'),
|
|
|
|
createGroup: action('createGroup'),
|
|
|
|
getPreferredBadge: () => undefined,
|
|
|
|
i18n,
|
|
|
|
preferredWidthFromStorage: 320,
|
|
|
|
openConversationInternal: action('openConversationInternal'),
|
|
|
|
regionCode: 'US',
|
|
|
|
challengeStatus: select(
|
|
|
|
'challengeStatus',
|
|
|
|
['idle', 'required', 'pending'],
|
|
|
|
'idle'
|
|
|
|
),
|
|
|
|
crashReportCount: select('challengeReportCount', [0, 1], 0),
|
|
|
|
setChallengeStatus: action('setChallengeStatus'),
|
|
|
|
lookupConversationWithoutUuid: makeFakeLookupConversationWithoutUuid(),
|
|
|
|
showUserNotFoundModal: action('showUserNotFoundModal'),
|
|
|
|
setIsFetchingUUID,
|
|
|
|
showConversation: action('showConversation'),
|
|
|
|
renderExpiredBuildDialog: () => <div />,
|
|
|
|
renderMainHeader: () => <div />,
|
|
|
|
renderMessageSearchResult: (id: string) => (
|
|
|
|
<MessageSearchResult
|
|
|
|
body="Lorem ipsum wow"
|
|
|
|
bodyRanges={[]}
|
|
|
|
conversationId="marc-convo"
|
|
|
|
from={defaultConversations[0]}
|
|
|
|
getPreferredBadge={() => undefined}
|
|
|
|
i18n={i18n}
|
|
|
|
id={id}
|
|
|
|
openConversationInternal={action('openConversationInternal')}
|
|
|
|
sentAt={1587358800000}
|
|
|
|
snippet="Lorem <<left>>ipsum<<right>> wow"
|
|
|
|
theme={ThemeType.light}
|
|
|
|
to={defaultConversations[1]}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
renderNetworkStatus: () => <div />,
|
|
|
|
renderRelinkDialog: () => <div />,
|
|
|
|
renderUpdateDialog: () => <div />,
|
|
|
|
renderCaptchaDialog: () => (
|
|
|
|
<CaptchaDialog
|
|
|
|
i18n={i18n}
|
|
|
|
isPending={overrideProps.challengeStatus === 'pending'}
|
|
|
|
onContinue={action('onCaptchaContinue')}
|
|
|
|
onSkip={action('onCaptchaSkip')}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
renderCrashReportDialog: () => (
|
|
|
|
<CrashReportDialog
|
|
|
|
i18n={i18n}
|
|
|
|
isPending={false}
|
|
|
|
uploadCrashReports={action('uploadCrashReports')}
|
|
|
|
eraseCrashReports={action('eraseCrashReports')}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
selectedConversationId: undefined,
|
|
|
|
selectedMessageId: undefined,
|
|
|
|
savePreferredLeftPaneWidth: action('savePreferredLeftPaneWidth'),
|
|
|
|
searchInConversation: action('searchInConversation'),
|
|
|
|
setComposeSearchTerm: action('setComposeSearchTerm'),
|
|
|
|
setComposeGroupAvatar: action('setComposeGroupAvatar'),
|
|
|
|
setComposeGroupName: action('setComposeGroupName'),
|
|
|
|
setComposeGroupExpireTimer: action('setComposeGroupExpireTimer'),
|
|
|
|
showArchivedConversations: action('showArchivedConversations'),
|
|
|
|
showInbox: action('showInbox'),
|
|
|
|
startComposing: action('startComposing'),
|
|
|
|
showChooseGroupMembers: action('showChooseGroupMembers'),
|
|
|
|
startSearch: action('startSearch'),
|
|
|
|
startSettingGroupMetadata: action('startSettingGroupMetadata'),
|
|
|
|
theme: React.useContext(StorybookThemeContext),
|
|
|
|
toggleComposeEditingAvatar: action('toggleComposeEditingAvatar'),
|
|
|
|
toggleConversationInChooseMembers: action(
|
|
|
|
'toggleConversationInChooseMembers'
|
|
|
|
),
|
|
|
|
updateSearchTerm: action('updateSearchTerm'),
|
|
|
|
|
|
|
|
...overrideProps,
|
|
|
|
|
|
|
|
modeSpecificProps,
|
|
|
|
};
|
|
|
|
};
|
2020-08-21 16:09:39 +00:00
|
|
|
|
2021-02-23 20:34:28 +00:00
|
|
|
// Inbox stories
|
2020-08-21 16:09:39 +00:00
|
|
|
|
2021-02-23 20:34:28 +00:00
|
|
|
story.add('Inbox: no conversations', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-02-23 20:34:28 +00:00
|
|
|
mode: LeftPaneMode.Inbox,
|
|
|
|
pinnedConversations: [],
|
|
|
|
conversations: [],
|
|
|
|
archivedConversations: [],
|
2021-10-12 23:59:08 +00:00
|
|
|
isAboutToSearchInAConversation: false,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
2020-08-21 16:09:39 +00:00
|
|
|
|
2021-02-23 20:34:28 +00:00
|
|
|
story.add('Inbox: only pinned conversations', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-02-23 20:34:28 +00:00
|
|
|
mode: LeftPaneMode.Inbox,
|
|
|
|
pinnedConversations,
|
|
|
|
conversations: [],
|
|
|
|
archivedConversations: [],
|
2021-10-12 23:59:08 +00:00
|
|
|
isAboutToSearchInAConversation: false,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
2020-09-29 22:07:03 +00:00
|
|
|
|
2021-02-23 20:34:28 +00:00
|
|
|
story.add('Inbox: only non-pinned conversations', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-02-23 20:34:28 +00:00
|
|
|
mode: LeftPaneMode.Inbox,
|
|
|
|
pinnedConversations: [],
|
|
|
|
conversations: defaultConversations,
|
|
|
|
archivedConversations: [],
|
2021-10-12 23:59:08 +00:00
|
|
|
isAboutToSearchInAConversation: false,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
2020-09-29 22:07:03 +00:00
|
|
|
|
2021-02-23 20:34:28 +00:00
|
|
|
story.add('Inbox: only archived conversations', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-02-23 20:34:28 +00:00
|
|
|
mode: LeftPaneMode.Inbox,
|
|
|
|
pinnedConversations: [],
|
|
|
|
conversations: [],
|
|
|
|
archivedConversations: defaultArchivedConversations,
|
2021-10-12 23:59:08 +00:00
|
|
|
isAboutToSearchInAConversation: false,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
2020-10-13 18:59:30 +00:00
|
|
|
|
2021-02-23 20:34:28 +00:00
|
|
|
story.add('Inbox: pinned and archived conversations', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-02-23 20:34:28 +00:00
|
|
|
mode: LeftPaneMode.Inbox,
|
|
|
|
pinnedConversations,
|
|
|
|
conversations: [],
|
|
|
|
archivedConversations: defaultArchivedConversations,
|
2021-10-12 23:59:08 +00:00
|
|
|
isAboutToSearchInAConversation: false,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
2020-10-13 18:59:30 +00:00
|
|
|
|
2021-02-23 20:34:28 +00:00
|
|
|
story.add('Inbox: non-pinned and archived conversations', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-02-23 20:34:28 +00:00
|
|
|
mode: LeftPaneMode.Inbox,
|
|
|
|
pinnedConversations: [],
|
|
|
|
conversations: defaultConversations,
|
|
|
|
archivedConversations: defaultArchivedConversations,
|
2021-10-12 23:59:08 +00:00
|
|
|
isAboutToSearchInAConversation: false,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
2020-08-21 16:09:39 +00:00
|
|
|
|
2021-02-23 20:34:28 +00:00
|
|
|
story.add('Inbox: pinned and non-pinned conversations', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-02-23 20:34:28 +00:00
|
|
|
mode: LeftPaneMode.Inbox,
|
|
|
|
pinnedConversations,
|
|
|
|
conversations: defaultConversations,
|
|
|
|
archivedConversations: [],
|
2021-10-12 23:59:08 +00:00
|
|
|
isAboutToSearchInAConversation: false,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Inbox: pinned, non-pinned, and archived conversations', () => (
|
2021-11-02 23:01:13 +00:00
|
|
|
<LeftPane {...useProps()} />
|
2021-02-23 20:34:28 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
// Search stories
|
|
|
|
|
|
|
|
story.add('Search: no results when searching everywhere', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-02-23 20:34:28 +00:00
|
|
|
mode: LeftPaneMode.Search,
|
|
|
|
conversationResults: emptySearchResultsGroup,
|
|
|
|
contactResults: emptySearchResultsGroup,
|
|
|
|
messageResults: emptySearchResultsGroup,
|
2021-05-19 16:14:35 +00:00
|
|
|
primarySendsSms: false,
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Search: no results when searching everywhere (SMS)', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-05-19 16:14:35 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-05-19 16:14:35 +00:00
|
|
|
mode: LeftPaneMode.Search,
|
|
|
|
conversationResults: emptySearchResultsGroup,
|
|
|
|
contactResults: emptySearchResultsGroup,
|
|
|
|
messageResults: emptySearchResultsGroup,
|
|
|
|
primarySendsSms: true,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Search: no results when searching in a conversation', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-02-23 20:34:28 +00:00
|
|
|
mode: LeftPaneMode.Search,
|
|
|
|
conversationResults: emptySearchResultsGroup,
|
|
|
|
contactResults: emptySearchResultsGroup,
|
|
|
|
messageResults: emptySearchResultsGroup,
|
|
|
|
searchConversationName: 'Bing Bong',
|
2021-05-19 16:14:35 +00:00
|
|
|
primarySendsSms: false,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Search: all results loading', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-02-23 20:34:28 +00:00
|
|
|
mode: LeftPaneMode.Search,
|
|
|
|
conversationResults: { isLoading: true },
|
|
|
|
contactResults: { isLoading: true },
|
|
|
|
messageResults: { isLoading: true },
|
2021-05-19 16:14:35 +00:00
|
|
|
primarySendsSms: false,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Search: some results loading', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-02-23 20:34:28 +00:00
|
|
|
mode: LeftPaneMode.Search,
|
|
|
|
conversationResults: {
|
|
|
|
isLoading: false,
|
|
|
|
results: defaultConversations,
|
2020-08-21 16:09:39 +00:00
|
|
|
},
|
2021-02-23 20:34:28 +00:00
|
|
|
contactResults: { isLoading: true },
|
|
|
|
messageResults: { isLoading: true },
|
2021-05-19 16:14:35 +00:00
|
|
|
primarySendsSms: false,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Search: has conversations and contacts, but not messages', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-02-23 20:34:28 +00:00
|
|
|
mode: LeftPaneMode.Search,
|
|
|
|
conversationResults: {
|
|
|
|
isLoading: false,
|
|
|
|
results: defaultConversations,
|
2020-08-21 16:09:39 +00:00
|
|
|
},
|
2021-02-23 20:34:28 +00:00
|
|
|
contactResults: { isLoading: false, results: defaultConversations },
|
|
|
|
messageResults: { isLoading: false, results: [] },
|
2021-05-19 16:14:35 +00:00
|
|
|
primarySendsSms: false,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Search: all results', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-02-23 20:34:28 +00:00
|
|
|
mode: LeftPaneMode.Search,
|
|
|
|
conversationResults: {
|
|
|
|
isLoading: false,
|
|
|
|
results: defaultConversations,
|
2020-08-21 16:09:39 +00:00
|
|
|
},
|
2021-02-23 20:34:28 +00:00
|
|
|
contactResults: { isLoading: false, results: defaultConversations },
|
|
|
|
messageResults: {
|
|
|
|
isLoading: false,
|
|
|
|
results: [
|
|
|
|
{ id: 'msg1', conversationId: 'foo' },
|
|
|
|
{ id: 'msg2', conversationId: 'bar' },
|
|
|
|
],
|
2020-08-21 16:09:39 +00:00
|
|
|
},
|
2021-05-19 16:14:35 +00:00
|
|
|
primarySendsSms: false,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
// Archived stories
|
|
|
|
|
|
|
|
story.add('Archive: no archived conversations', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Archive,
|
|
|
|
archivedConversations: [],
|
2021-11-01 18:43:02 +00:00
|
|
|
searchConversation: undefined,
|
|
|
|
searchTerm: '',
|
2022-02-02 15:30:39 +00:00
|
|
|
startSearchCounter: 0,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Archive: archived conversations', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Archive,
|
|
|
|
archivedConversations: defaultConversations,
|
2021-11-01 18:43:02 +00:00
|
|
|
searchConversation: undefined,
|
|
|
|
searchTerm: '',
|
2022-02-02 15:30:39 +00:00
|
|
|
startSearchCounter: 0,
|
2021-11-01 18:43:02 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Archive: searching a conversation', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-11-01 18:43:02 +00:00
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Archive,
|
|
|
|
archivedConversations: defaultConversations,
|
2021-12-01 02:14:25 +00:00
|
|
|
searchConversation: undefined,
|
|
|
|
searchTerm: '',
|
2022-02-02 15:30:39 +00:00
|
|
|
startSearchCounter: 0,
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
// Compose stories
|
|
|
|
|
2021-11-12 01:17:29 +00:00
|
|
|
story.add('Compose: no results', () => (
|
2021-02-23 20:34:28 +00:00
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Compose,
|
|
|
|
composeContacts: [],
|
2021-04-20 23:16:49 +00:00
|
|
|
composeGroups: [],
|
2021-11-12 01:17:29 +00:00
|
|
|
isUsernamesEnabled: true,
|
2022-04-05 00:38:22 +00:00
|
|
|
uuidFetchState: {},
|
2021-02-23 20:34:28 +00:00
|
|
|
regionCode: 'US',
|
|
|
|
searchTerm: '',
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
2021-11-12 01:17:29 +00:00
|
|
|
story.add('Compose: some contacts, no search term', () => (
|
2021-02-23 20:34:28 +00:00
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Compose,
|
|
|
|
composeContacts: defaultConversations,
|
2021-04-20 23:16:49 +00:00
|
|
|
composeGroups: [],
|
2021-11-12 01:17:29 +00:00
|
|
|
isUsernamesEnabled: true,
|
2022-04-05 00:38:22 +00:00
|
|
|
uuidFetchState: {},
|
2021-02-23 20:34:28 +00:00
|
|
|
regionCode: 'US',
|
|
|
|
searchTerm: '',
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
2021-11-12 01:17:29 +00:00
|
|
|
story.add('Compose: some contacts, with a search term', () => (
|
2021-02-23 20:34:28 +00:00
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-02-23 20:34:28 +00:00
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Compose,
|
|
|
|
composeContacts: defaultConversations,
|
2021-04-20 23:16:49 +00:00
|
|
|
composeGroups: [],
|
2021-11-12 01:17:29 +00:00
|
|
|
isUsernamesEnabled: true,
|
2022-04-05 00:38:22 +00:00
|
|
|
uuidFetchState: {},
|
2021-02-23 20:34:28 +00:00
|
|
|
regionCode: 'US',
|
2021-04-20 23:16:49 +00:00
|
|
|
searchTerm: 'ar',
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
2021-11-12 01:17:29 +00:00
|
|
|
story.add('Compose: some groups, no search term', () => (
|
2021-04-20 23:16:49 +00:00
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-04-20 23:16:49 +00:00
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Compose,
|
|
|
|
composeContacts: [],
|
|
|
|
composeGroups: defaultGroups,
|
2021-11-12 01:17:29 +00:00
|
|
|
isUsernamesEnabled: true,
|
2022-04-05 00:38:22 +00:00
|
|
|
uuidFetchState: {},
|
2021-04-20 23:16:49 +00:00
|
|
|
regionCode: 'US',
|
|
|
|
searchTerm: '',
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
2021-11-12 01:17:29 +00:00
|
|
|
story.add('Compose: some groups, with search term', () => (
|
2021-04-20 23:16:49 +00:00
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-04-20 23:16:49 +00:00
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Compose,
|
|
|
|
composeContacts: [],
|
|
|
|
composeGroups: defaultGroups,
|
2021-11-12 01:17:29 +00:00
|
|
|
isUsernamesEnabled: true,
|
2022-04-05 00:38:22 +00:00
|
|
|
uuidFetchState: {},
|
2021-04-20 23:16:49 +00:00
|
|
|
regionCode: 'US',
|
|
|
|
searchTerm: 'ar',
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
2021-11-12 01:17:29 +00:00
|
|
|
story.add('Compose: search is valid username', () => (
|
|
|
|
<LeftPane
|
|
|
|
{...useProps({
|
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Compose,
|
|
|
|
composeContacts: [],
|
|
|
|
composeGroups: [],
|
|
|
|
isUsernamesEnabled: true,
|
2022-04-05 00:38:22 +00:00
|
|
|
uuidFetchState: {},
|
2021-11-12 01:17:29 +00:00
|
|
|
regionCode: 'US',
|
|
|
|
searchTerm: 'someone',
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Compose: search is valid username, fetching username', () => (
|
|
|
|
<LeftPane
|
|
|
|
{...useProps({
|
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Compose,
|
|
|
|
composeContacts: [],
|
|
|
|
composeGroups: [],
|
|
|
|
isUsernamesEnabled: true,
|
2022-04-05 00:38:22 +00:00
|
|
|
uuidFetchState: {
|
|
|
|
'username:someone': true,
|
|
|
|
},
|
2021-11-12 01:17:29 +00:00
|
|
|
regionCode: 'US',
|
|
|
|
searchTerm: 'someone',
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Compose: search is valid username, but flag is not enabled', () => (
|
|
|
|
<LeftPane
|
|
|
|
{...useProps({
|
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Compose,
|
|
|
|
composeContacts: [],
|
|
|
|
composeGroups: [],
|
|
|
|
isUsernamesEnabled: false,
|
2022-04-05 00:38:22 +00:00
|
|
|
uuidFetchState: {},
|
2021-11-12 01:17:29 +00:00
|
|
|
regionCode: 'US',
|
|
|
|
searchTerm: 'someone',
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
2022-04-05 00:38:22 +00:00
|
|
|
story.add('Compose: search is partial phone number', () => (
|
|
|
|
<LeftPane
|
|
|
|
{...useProps({
|
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Compose,
|
|
|
|
composeContacts: [],
|
|
|
|
composeGroups: [],
|
|
|
|
isUsernamesEnabled: false,
|
|
|
|
uuidFetchState: {},
|
|
|
|
regionCode: 'US',
|
|
|
|
searchTerm: '+1(212)555',
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Compose: search is valid phone number', () => (
|
|
|
|
<LeftPane
|
|
|
|
{...useProps({
|
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Compose,
|
|
|
|
composeContacts: [],
|
|
|
|
composeGroups: [],
|
|
|
|
isUsernamesEnabled: true,
|
|
|
|
uuidFetchState: {},
|
|
|
|
regionCode: 'US',
|
|
|
|
searchTerm: '2125555454',
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add(
|
|
|
|
'Compose: search is valid phone number, fetching phone number',
|
|
|
|
() => (
|
|
|
|
<LeftPane
|
|
|
|
{...useProps({
|
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Compose,
|
|
|
|
composeContacts: [],
|
|
|
|
composeGroups: [],
|
|
|
|
isUsernamesEnabled: true,
|
|
|
|
uuidFetchState: {
|
|
|
|
'e164:+12125555454': true,
|
|
|
|
},
|
|
|
|
regionCode: 'US',
|
|
|
|
searchTerm: '(212)5555454',
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2021-11-12 01:17:29 +00:00
|
|
|
story.add('Compose: all kinds of results, no search term', () => (
|
2021-04-20 23:16:49 +00:00
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-04-20 23:16:49 +00:00
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Compose,
|
|
|
|
composeContacts: defaultConversations,
|
|
|
|
composeGroups: defaultGroups,
|
2021-11-12 01:17:29 +00:00
|
|
|
isUsernamesEnabled: true,
|
2022-04-05 00:38:22 +00:00
|
|
|
uuidFetchState: {},
|
2021-04-20 23:16:49 +00:00
|
|
|
regionCode: 'US',
|
|
|
|
searchTerm: '',
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
2021-11-12 01:17:29 +00:00
|
|
|
story.add('Compose: all kinds of results, with a search term', () => (
|
2021-04-20 23:16:49 +00:00
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-04-20 23:16:49 +00:00
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.Compose,
|
|
|
|
composeContacts: defaultConversations,
|
|
|
|
composeGroups: defaultGroups,
|
2021-11-12 01:17:29 +00:00
|
|
|
isUsernamesEnabled: true,
|
2022-04-05 00:38:22 +00:00
|
|
|
uuidFetchState: {},
|
2021-04-20 23:16:49 +00:00
|
|
|
regionCode: 'US',
|
2021-11-12 01:17:29 +00:00
|
|
|
searchTerm: 'someone',
|
2021-02-23 20:34:28 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
2021-05-06 00:09:29 +00:00
|
|
|
|
|
|
|
// Captcha flow
|
|
|
|
|
|
|
|
story.add('Captcha dialog: required', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-05-06 00:09:29 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-05-06 00:09:29 +00:00
|
|
|
mode: LeftPaneMode.Inbox,
|
|
|
|
pinnedConversations,
|
|
|
|
conversations: defaultConversations,
|
|
|
|
archivedConversations: [],
|
2021-10-12 23:59:08 +00:00
|
|
|
isAboutToSearchInAConversation: false,
|
2022-01-27 22:12:26 +00:00
|
|
|
searchTerm: '',
|
2021-05-06 00:09:29 +00:00
|
|
|
},
|
|
|
|
challengeStatus: 'required',
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Captcha dialog: pending', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-05-06 00:09:29 +00:00
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2021-05-06 00:09:29 +00:00
|
|
|
mode: LeftPaneMode.Inbox,
|
|
|
|
pinnedConversations,
|
|
|
|
conversations: defaultConversations,
|
|
|
|
archivedConversations: [],
|
2021-10-12 23:59:08 +00:00
|
|
|
isAboutToSearchInAConversation: false,
|
2022-01-27 22:12:26 +00:00
|
|
|
searchTerm: '',
|
2021-05-06 00:09:29 +00:00
|
|
|
},
|
|
|
|
challengeStatus: 'pending',
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
2021-06-25 23:52:56 +00:00
|
|
|
|
2022-01-11 20:02:46 +00:00
|
|
|
// Crash report flow
|
|
|
|
|
|
|
|
story.add('Crash report dialog', () => (
|
|
|
|
<LeftPane
|
|
|
|
{...useProps({
|
|
|
|
modeSpecificProps: {
|
2022-01-27 22:12:26 +00:00
|
|
|
...defaultSearchProps,
|
2022-01-11 20:02:46 +00:00
|
|
|
mode: LeftPaneMode.Inbox,
|
|
|
|
pinnedConversations,
|
|
|
|
conversations: defaultConversations,
|
|
|
|
archivedConversations: [],
|
|
|
|
isAboutToSearchInAConversation: false,
|
2022-01-27 22:12:26 +00:00
|
|
|
searchTerm: '',
|
2022-01-11 20:02:46 +00:00
|
|
|
},
|
|
|
|
crashReportCount: 42,
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
2022-04-05 00:38:22 +00:00
|
|
|
// Choose Group Members
|
|
|
|
|
|
|
|
story.add('Choose Group Members: Partial phone number', () => (
|
|
|
|
<LeftPane
|
|
|
|
{...useProps({
|
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.ChooseGroupMembers,
|
|
|
|
uuidFetchState: {},
|
|
|
|
candidateContacts: [],
|
|
|
|
isShowingRecommendedGroupSizeModal: false,
|
|
|
|
isShowingMaximumGroupSizeModal: false,
|
|
|
|
searchTerm: '+1(212) 555',
|
|
|
|
regionCode: 'US',
|
|
|
|
selectedContacts: [],
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Choose Group Members: Valid phone number', () => (
|
|
|
|
<LeftPane
|
|
|
|
{...useProps({
|
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.ChooseGroupMembers,
|
|
|
|
uuidFetchState: {},
|
|
|
|
candidateContacts: [],
|
|
|
|
isShowingRecommendedGroupSizeModal: false,
|
|
|
|
isShowingMaximumGroupSizeModal: false,
|
|
|
|
searchTerm: '+1(212) 555 5454',
|
|
|
|
regionCode: 'US',
|
|
|
|
selectedContacts: [],
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
2021-06-25 23:52:56 +00:00
|
|
|
// Set group metadata
|
|
|
|
|
|
|
|
story.add('Group Metadata: No Timer', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-06-25 23:52:56 +00:00
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.SetGroupMetadata,
|
|
|
|
groupAvatar: undefined,
|
|
|
|
groupName: 'Group 1',
|
|
|
|
groupExpireTimer: 0,
|
|
|
|
hasError: false,
|
|
|
|
isCreating: false,
|
2021-08-06 00:17:05 +00:00
|
|
|
isEditingAvatar: false,
|
2021-06-25 23:52:56 +00:00
|
|
|
selectedContacts: defaultConversations,
|
2021-08-06 00:17:05 +00:00
|
|
|
userAvatarData: [],
|
2021-06-25 23:52:56 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Group Metadata: Regular Timer', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-06-25 23:52:56 +00:00
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.SetGroupMetadata,
|
|
|
|
groupAvatar: undefined,
|
|
|
|
groupName: 'Group 1',
|
|
|
|
groupExpireTimer: 24 * 3600,
|
|
|
|
hasError: false,
|
|
|
|
isCreating: false,
|
2021-08-06 00:17:05 +00:00
|
|
|
isEditingAvatar: false,
|
2021-06-25 23:52:56 +00:00
|
|
|
selectedContacts: defaultConversations,
|
2021-08-06 00:17:05 +00:00
|
|
|
userAvatarData: [],
|
2021-06-25 23:52:56 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Group Metadata: Custom Timer', () => (
|
|
|
|
<LeftPane
|
2021-11-02 23:01:13 +00:00
|
|
|
{...useProps({
|
2021-06-25 23:52:56 +00:00
|
|
|
modeSpecificProps: {
|
|
|
|
mode: LeftPaneMode.SetGroupMetadata,
|
|
|
|
groupAvatar: undefined,
|
|
|
|
groupName: 'Group 1',
|
|
|
|
groupExpireTimer: 7 * 3600,
|
|
|
|
hasError: false,
|
|
|
|
isCreating: false,
|
2021-08-06 00:17:05 +00:00
|
|
|
isEditingAvatar: false,
|
2021-06-25 23:52:56 +00:00
|
|
|
selectedContacts: defaultConversations,
|
2021-08-06 00:17:05 +00:00
|
|
|
userAvatarData: [],
|
2021-06-25 23:52:56 +00:00
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
2022-01-27 22:12:26 +00:00
|
|
|
|
|
|
|
story.add('Searching Conversation', () => (
|
|
|
|
<LeftPane
|
|
|
|
{...useProps({
|
|
|
|
modeSpecificProps: {
|
|
|
|
...defaultSearchProps,
|
|
|
|
mode: LeftPaneMode.Inbox,
|
|
|
|
pinnedConversations: [],
|
|
|
|
conversations: defaultConversations,
|
|
|
|
archivedConversations: [],
|
|
|
|
isAboutToSearchInAConversation: false,
|
|
|
|
searchConversation: getDefaultConversation(),
|
|
|
|
searchTerm: '',
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|