// Copyright 2020 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './LeftPane'; import { LeftPane } from './LeftPane'; import { CaptchaDialog } from './CaptchaDialog'; import { CrashReportDialog } from './CrashReportDialog'; import { ToastManager } from './ToastManager'; import type { PropsType as DialogNetworkStatusPropsType } from './DialogNetworkStatus'; import { DialogExpiredBuild } from './DialogExpiredBuild'; import { DialogNetworkStatus } from './DialogNetworkStatus'; import { DialogRelink } from './DialogRelink'; import type { PropsType as DialogUpdatePropsType } from './DialogUpdate'; import { DialogUpdate } from './DialogUpdate'; import { UnsupportedOSDialog } from './UnsupportedOSDialog'; import type { ConversationType } from '../state/ducks/conversations'; import { MessageSearchResult } from './conversationList/MessageSearchResult'; import { setupI18n } from '../util/setupI18n'; import { DurationInSeconds, DAY } from '../util/durations'; import enMessages from '../../_locales/en/messages.json'; import { LeftPaneMode } from '../types/leftPane'; import { ThemeType } from '../types/Util'; import { getDefaultConversation, getDefaultGroupListItem, } from '../test-both/helpers/getDefaultConversation'; import { DialogType } from '../types/Dialogs'; import { SocketStatus } from '../types/SocketStatus'; import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext'; import { makeFakeLookupConversationWithoutServiceId, useUuidFetchState, } from '../test-both/helpers/fakeLookupConversationWithoutServiceId'; import type { GroupListItemConversationType } from './conversationList/GroupListItem'; const i18n = setupI18n('en', enMessages); type OverridePropsType = Partial & { dialogNetworkStatus?: Partial; dialogUpdate?: Partial; }; export default { title: 'Components/LeftPane', argTypes: {}, args: {}, } satisfies Meta; const defaultConversations: Array = [ getDefaultConversation({ id: 'fred-convo', title: 'Fred Willard', }), getDefaultConversation({ id: 'marc-convo', isSelected: true, title: 'Marc Barraca', }), ]; const defaultSearchProps = { searchConversation: undefined, searchDisabled: false, searchTerm: 'hello', startSearchCounter: 0, }; const defaultGroups: Array = [ getDefaultGroupListItem({ id: 'biking-group', title: 'Mtn Biking Arizona 🚵☀️⛰', }), getDefaultGroupListItem({ id: 'dance-group', title: 'Are we dancers? 💃', }), ]; const defaultArchivedConversations: Array = [ getDefaultConversation({ id: 'michelle-archive-convo', title: 'Michelle Mercure', isArchived: true, }), ]; const pinnedConversations: Array = [ getDefaultConversation({ id: 'philly-convo', isPinned: true, title: 'Philip Glass', }), getDefaultConversation({ id: 'robbo-convo', isPinned: true, title: 'Robert Moog', }), ]; const defaultModeSpecificProps = { ...defaultSearchProps, mode: LeftPaneMode.Inbox as const, pinnedConversations, conversations: defaultConversations, archivedConversations: defaultArchivedConversations, isAboutToSearch: false, }; const emptySearchResultsGroup = { isLoading: false, results: [] }; const useProps = (overrideProps: OverridePropsType = {}): PropsType => { let modeSpecificProps = overrideProps.modeSpecificProps ?? defaultModeSpecificProps; const [uuidFetchState, setIsFetchingUUID] = useUuidFetchState( 'uuidFetchState' in modeSpecificProps ? modeSpecificProps.uuidFetchState : {} ); if ('uuidFetchState' in modeSpecificProps) { modeSpecificProps = { ...modeSpecificProps, uuidFetchState, }; } const isUpdateDownloaded = false; return { otherTabsUnreadStats: { unreadCount: 0, unreadMentionsCount: 0, markedUnread: false, }, 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, hasFailedStorySends: false, hasPendingUpdate: false, i18n, isMacOS: false, preferredWidthFromStorage: 320, challengeStatus: 'idle', crashReportCount: 0, hasNetworkDialog: false, hasExpiredDialog: false, hasRelinkDialog: false, hasUpdateDialog: false, unsupportedOSDialogType: undefined, usernameCorrupted: false, usernameLinkCorrupted: false, isUpdateDownloaded, navTabsCollapsed: false, setChallengeStatus: action('setChallengeStatus'), lookupConversationWithoutServiceId: makeFakeLookupConversationWithoutServiceId(), showUserNotFoundModal: action('showUserNotFoundModal'), setIsFetchingUUID, showConversation: action('showConversation'), blockConversation: action('blockConversation'), onOutgoingAudioCallInConversation: action( 'onOutgoingAudioCallInConversation' ), onOutgoingVideoCallInConversation: action( 'onOutgoingVideoCallInConversation' ), removeConversation: action('removeConversation'), renderMessageSearchResult: (id: string) => ( undefined} i18n={i18n} id={id} sentAt={1587358800000} showConversation={action('showConversation')} snippet="Lorem <>ipsum<> wow" theme={ThemeType.light} to={defaultConversations[1]} /> ), renderNetworkStatus: props => ( ), renderRelinkDialog: props => ( ), renderUpdateDialog: props => ( ), renderCaptchaDialog: () => ( ), renderCrashReportDialog: () => ( ), renderExpiredBuildDialog: props => , renderUnsupportedOSDialog: props => ( ), renderToastManager: ({ containerWidthBreakpoint }) => ( ), selectedConversationId: undefined, targetedMessageId: undefined, openUsernameReservationModal: action('openUsernameReservationModal'), savePreferredLeftPaneWidth: action('savePreferredLeftPaneWidth'), searchInConversation: action('searchInConversation'), setComposeSearchTerm: action('setComposeSearchTerm'), setComposeSelectedRegion: action('setComposeSelectedRegion'), setComposeGroupAvatar: action('setComposeGroupAvatar'), setComposeGroupName: action('setComposeGroupName'), setComposeGroupExpireTimer: action('setComposeGroupExpireTimer'), showArchivedConversations: action('showArchivedConversations'), showInbox: action('showInbox'), startComposing: action('startComposing'), showChooseGroupMembers: action('showChooseGroupMembers'), showFindByUsername: action('showFindByUsername'), showFindByPhoneNumber: action('showFindByPhoneNumber'), startSearch: action('startSearch'), startSettingGroupMetadata: action('startSettingGroupMetadata'), theme: React.useContext(StorybookThemeContext), toggleComposeEditingAvatar: action('toggleComposeEditingAvatar'), toggleConversationInChooseMembers: action( 'toggleConversationInChooseMembers' ), toggleNavTabsCollapse: action('toggleNavTabsCollapse'), toggleProfileEditor: action('toggleProfileEditor'), updateSearchTerm: action('updateSearchTerm'), ...overrideProps, modeSpecificProps, }; }; function LeftPaneInContainer(props: PropsType): JSX.Element { return (
); } export function InboxNoConversations(): JSX.Element { return ( ); } export function InboxUsernameCorrupted(): JSX.Element { return ( ); } export function InboxUsernameLinkCorrupted(): JSX.Element { return ( ); } export function InboxOnlyPinnedConversations(): JSX.Element { return ( ); } export function InboxOnlyNonPinnedConversations(): JSX.Element { return ( ); } export function InboxOnlyArchivedConversations(): JSX.Element { return ( ); } export function InboxPinnedAndArchivedConversations(): JSX.Element { return ( ); } export function InboxNonPinnedAndArchivedConversations(): JSX.Element { return ( ); } export function InboxPinnedAndNonPinnedConversations(): JSX.Element { return ( ); } export function InboxPinnedNonPinnedAndArchivedConversations(): JSX.Element { return ; } export function SearchNoResultsWhenSearchingEverywhere(): JSX.Element { return ( ); } export function SearchNoResultsWhenSearchingEverywhereSms(): JSX.Element { return ( ); } export function SearchNoResultsWhenSearchingInAConversation(): JSX.Element { return ( ); } export function SearchAllResultsLoading(): JSX.Element { return ( ); } export function SearchSomeResultsLoading(): JSX.Element { return ( ); } export function SearchHasConversationsAndContactsButNotMessages(): JSX.Element { return ( ); } export function SearchAllResults(): JSX.Element { return ( ); } export function ArchiveNoArchivedConversations(): JSX.Element { return ( ); } export function ArchiveArchivedConversations(): JSX.Element { return ( ); } export function ArchiveSearchingAConversation(): JSX.Element { return ( ); } export function ComposeNoResults(): JSX.Element { return ( ); } export function ComposeSomeContactsNoSearchTerm(): JSX.Element { return ( ); } export function ComposeSomeContactsWithASearchTerm(): JSX.Element { return ( ); } export function ComposeSomeGroupsNoSearchTerm(): JSX.Element { return ( ); } export function ComposeSomeGroupsWithSearchTerm(): JSX.Element { return ( ); } export function ComposeSearchIsValidUsername(): JSX.Element { return ( ); } export function ComposeSearchIsValidUsernameFetchingUsername(): JSX.Element { return ( ); } export function ComposeSearchIsValidPhoneNumber(): JSX.Element { return ( ); } export function ComposeSearchIsValidPhoneNumberFetchingPhoneNumber(): JSX.Element { return ( ); } export function ComposeAllKindsOfResultsNoSearchTerm(): JSX.Element { return ( ); } export function ComposeAllKindsOfResultsWithASearchTerm(): JSX.Element { return ( ); } export function CaptchaDialogRequired(): JSX.Element { return ( ); } export function CaptchaDialogPending(): JSX.Element { return ( ); } export function _CrashReportDialog(): JSX.Element { return ( ); } export function ChooseGroupMembersPartialPhoneNumber(): JSX.Element { return ( ); } export function ChooseGroupMembersValidPhoneNumber(): JSX.Element { return ( ); } export function ChooseGroupMembersUsername(): JSX.Element { return ( ); } export function GroupMetadataNoTimer(): JSX.Element { return ( ); } export function GroupMetadataRegularTimer(): JSX.Element { return ( ); } export function GroupMetadataCustomTimer(): JSX.Element { return ( ); } export function SearchingConversation(): JSX.Element { return ( ); }