// 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 { PropsData as MessageDataPropsType } from './Message'; import { TextDirection } from './Message'; import type { Props } from './MessageDetail'; import { MessageDetail } from './MessageDetail'; import { SendStatus } from '../../messages/MessageSendState'; import { ReadStatus } from '../../messages/MessageReadStatus'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; import { setupI18n } from '../../util/setupI18n'; import enMessages from '../../../_locales/en/messages.json'; import { getFakeBadge } from '../../test-both/helpers/getFakeBadge'; import { ThemeType } from '../../types/Util'; const i18n = setupI18n('en', enMessages); const defaultMessage: MessageDataPropsType = { author: getDefaultConversation({ id: 'some-id', title: 'Max', }), canDeleteForEveryone: true, conversationColor: 'crimson', conversationId: 'my-convo', conversationTitle: 'Conversation Title', conversationType: 'direct', direction: 'incoming', id: 'my-message', renderingContext: 'storybook', renderMenu: undefined, isBlocked: false, isMessageRequestAccepted: true, isSelected: false, isSelectMode: false, isSMS: false, isSpoilerExpanded: {}, previews: [], readStatus: ReadStatus.Read, status: 'sent', text: 'A message from Max', textDirection: TextDirection.Default, timestamp: Date.now(), }; export default { title: 'Components/Conversation/MessageDetail', argTypes: { message: { control: { type: 'text' } }, receivedAt: { control: { type: 'number' } }, sentAt: { control: { type: 'number' } }, }, args: { contacts: [ { ...getDefaultConversation({ title: 'Just Max', }), isOutgoingKeyError: false, isUnidentifiedDelivery: false, status: SendStatus.Delivered, }, ], errors: [], message: defaultMessage, receivedAt: Date.now(), sentAt: Date.now(), getPreferredBadge: () => getFakeBadge(), i18n, platform: 'darwin', interactionMode: 'keyboard', theme: ThemeType.light, toggleSafetyNumberModal: action('toggleSafetyNumberModal'), checkForAccount: action('checkForAccount'), clearTargetedMessage: action('clearTargetedMessage'), showLightboxForViewOnceMedia: action('showLightboxForViewOnceMedia'), doubleCheckMissingQuoteReference: action( 'doubleCheckMissingQuoteReference' ), kickOffAttachmentDownload: action('kickOffAttachmentDownload'), markAttachmentAsCorrupted: action('markAttachmentAsCorrupted'), messageExpanded: action('messageExpanded'), showConversation: action('showConversation'), openGiftBadge: action('openGiftBadge'), renderAudioAttachment: () =>