// Copyright 2020-2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import * as React from 'react'; import { action } from '@storybook/addon-actions'; import { storiesOf } from '@storybook/react'; import { LeftPane, LeftPaneMode, PropsType } from './LeftPane'; import { PropsData as ConversationListItemPropsType } from './conversationList/ConversationListItem'; import { MessageSearchResult } from './conversationList/MessageSearchResult'; import { setup as setupI18n } from '../../js/modules/i18n'; import enMessages from '../../_locales/en/messages.json'; const i18n = setupI18n('en', enMessages); const story = storiesOf('Components/LeftPane', module); const defaultConversations: Array = [ { id: 'fred-convo', isSelected: false, lastUpdated: Date.now(), markedUnread: false, title: 'Fred Willard', type: 'direct', }, { id: 'marc-convo', isSelected: true, lastUpdated: Date.now(), markedUnread: false, title: 'Marc Barraca', type: 'direct', }, ]; const defaultArchivedConversations: Array = [ { id: 'michelle-archive-convo', isSelected: false, lastUpdated: Date.now(), markedUnread: false, title: 'Michelle Mercure', type: 'direct', }, ]; const pinnedConversations: Array = [ { id: 'philly-convo', isPinned: true, isSelected: false, lastUpdated: Date.now(), markedUnread: false, title: 'Philip Glass', type: 'direct', }, { id: 'robbo-convo', isPinned: true, isSelected: false, lastUpdated: Date.now(), markedUnread: false, title: 'Robert Moog', type: 'direct', }, ]; const defaultModeSpecificProps = { mode: LeftPaneMode.Inbox as const, pinnedConversations, conversations: defaultConversations, archivedConversations: defaultArchivedConversations, }; const emptySearchResultsGroup = { isLoading: false, results: [] }; const createProps = (overrideProps: Partial = {}): PropsType => ({ cantAddContactToGroup: action('cantAddContactToGroup'), clearGroupCreationError: action('clearGroupCreationError'), closeCantAddContactToGroupModal: action('closeCantAddContactToGroupModal'), closeMaximumGroupSizeModal: action('closeMaximumGroupSizeModal'), closeRecommendedGroupSizeModal: action('closeRecommendedGroupSizeModal'), createGroup: action('createGroup'), i18n, modeSpecificProps: defaultModeSpecificProps, openConversationInternal: action('openConversationInternal'), regionCode: 'US', renderExpiredBuildDialog: () =>
, renderMainHeader: () =>
, renderMessageSearchResult: (id: string, style: React.CSSProperties) => ( ), renderNetworkStatus: () =>
, renderRelinkDialog: () =>
, renderUpdateDialog: () =>
, selectedConversationId: undefined, selectedMessageId: undefined, setComposeSearchTerm: action('setComposeSearchTerm'), setComposeGroupAvatar: action('setComposeGroupAvatar'), setComposeGroupName: action('setComposeGroupName'), showArchivedConversations: action('showArchivedConversations'), showInbox: action('showInbox'), startComposing: action('startComposing'), showChooseGroupMembers: action('showChooseGroupMembers'), startNewConversationFromPhoneNumber: action( 'startNewConversationFromPhoneNumber' ), startSettingGroupMetadata: action('startSettingGroupMetadata'), toggleConversationInChooseMembers: action( 'toggleConversationInChooseMembers' ), ...overrideProps, }); // Inbox stories story.add('Inbox: no conversations', () => ( )); story.add('Inbox: only pinned conversations', () => ( )); story.add('Inbox: only non-pinned conversations', () => ( )); story.add('Inbox: only archived conversations', () => ( )); story.add('Inbox: pinned and archived conversations', () => ( )); story.add('Inbox: non-pinned and archived conversations', () => ( )); story.add('Inbox: pinned and non-pinned conversations', () => ( )); story.add('Inbox: pinned, non-pinned, and archived conversations', () => ( )); // Search stories story.add('Search: no results when searching everywhere', () => ( )); story.add('Search: no results when searching in a conversation', () => ( )); story.add('Search: all results loading', () => ( )); story.add('Search: some results loading', () => ( )); story.add('Search: has conversations and contacts, but not messages', () => ( )); story.add('Search: all results', () => ( )); // Archived stories story.add('Archive: no archived conversations', () => ( )); story.add('Archive: archived conversations', () => ( )); // Compose stories story.add('Compose: no contacts', () => ( )); story.add('Compose: some contacts, no search term', () => ( )); story.add('Compose: some contacts with a search term', () => ( ));