// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import * as React from 'react'; import { action } from '@storybook/addon-actions'; import { text } from '@storybook/addon-knobs'; import enMessages from '../../_locales/en/messages.json'; import type { AttachmentType } from '../types/Attachment'; import type { PropsType } from './ForwardMessagesModal'; import { ForwardMessagesModal } from './ForwardMessagesModal'; import { IMAGE_JPEG, VIDEO_MP4, stringToMIMEType } from '../types/MIME'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import { setupI18n } from '../util/setupI18n'; import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext'; import { CompositionTextArea } from './CompositionTextArea'; import type { MessageForwardDraft } from '../util/maybeForwardMessages'; const createAttachment = ( props: Partial = {} ): AttachmentType => ({ pending: false, path: 'fileName.jpg', contentType: stringToMIMEType( text('attachment contentType', props.contentType || '') ), fileName: text('attachment fileName', props.fileName || ''), screenshotPath: props.pending === false ? props.screenshotPath : undefined, url: text('attachment url', props.pending === false ? props.url || '' : ''), size: 3433, }); export default { title: 'Components/ForwardMessageModal', }; const i18n = setupI18n('en', enMessages); const LONG_TITLE = "This is a super-sweet site. And it's got some really amazing content in store for you if you just click that link. Can you click that link for me?"; const LONG_DESCRIPTION = "You're gonna love this description. Not only does it have a lot of characters, but it will also be truncated in the UI. How cool is that??"; const candidateConversations = Array.from(Array(100), () => getDefaultConversation() ); const useProps = (overrideProps: Partial = {}): PropsType => ({ drafts: overrideProps.drafts ?? [], candidateConversations, doForwardMessages: action('doForwardMessages'), getPreferredBadge: () => undefined, i18n, linkPreviewForSource: () => undefined, onClose: action('onClose'), onChange: action('onChange'), removeLinkPreview: action('removeLinkPreview'), RenderCompositionTextArea: props => ( undefined} /> ), showToast: action('showToast'), theme: React.useContext(StorybookThemeContext), regionCode: 'US', }); function getMessageForwardDraft( overrideProps: Partial ): MessageForwardDraft { return { attachments: overrideProps.attachments, hasContact: Boolean(overrideProps.hasContact), isSticker: Boolean(overrideProps.isSticker), messageBody: text('messageBody', overrideProps.messageBody || ''), originalMessageId: '123', previews: overrideProps.previews ?? [], }; } export function Modal(): JSX.Element { return ; } export function WithText(): JSX.Element { return ( ); } WithText.story = { name: 'with text', }; export function ASticker(): JSX.Element { return ( ); } ASticker.story = { name: 'a sticker', }; export function WithAContact(): JSX.Element { return ( ); } WithAContact.story = { name: 'with a contact', }; export function LinkPreview(): JSX.Element { return ( ); } LinkPreview.story = { name: 'link preview', }; export function MediaAttachments(): JSX.Element { return ( ); } MediaAttachments.story = { name: 'media attachments', }; export function AnnouncementOnlyGroupsNonAdmin(): JSX.Element { return ( ); } AnnouncementOnlyGroupsNonAdmin.story = { name: 'announcement only groups non-admin', };