// Copyright 2023 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React, { type ReactNode } from 'react'; import type { LocalizerType } from '../../types/I18N.std.js'; import { AxoMenuBuilder } from '../../axo/AxoMenuBuilder.dom.js'; import { isPinnedMessagesReceiveEnabled } from '../../util/isPinnedMessagesEnabled.std.js'; type MessageContextMenuProps = Readonly<{ i18n: LocalizerType; renderer: AxoMenuBuilder.Renderer; onOpenChange?: (open: boolean) => void; disabled?: boolean; shouldShowAdditional: boolean; onDownload: (() => void) | null; onEdit: (() => void) | null; onReplyToMessage: (() => void) | null; onReact: (() => void) | null; onEndPoll: (() => void) | null; onRetryMessageSend: (() => void) | null; onRetryDeleteForEveryone: (() => void) | null; onCopy: (() => void) | null; onForward: (() => void) | null; onDeleteMessage: (() => void) | null; onPinMessage: (() => void) | null; onMoreInfo: (() => void) | null; onSelect: (() => void) | null; children: ReactNode; }>; export function MessageContextMenu({ i18n, renderer, onOpenChange, disabled, shouldShowAdditional, onDownload, onEdit, onReplyToMessage, onReact, onEndPoll, onMoreInfo, onCopy, onSelect, onRetryMessageSend, onRetryDeleteForEveryone, onForward, onDeleteMessage, onPinMessage, children, }: MessageContextMenuProps): JSX.Element { return ( {children} {shouldShowAdditional && ( <> {onDownload && ( {i18n('icu:MessageContextMenu__download')} )} {onReplyToMessage && ( {i18n('icu:MessageContextMenu__reply')} )} {onReact && ( {i18n('icu:MessageContextMenu__react')} )} )} {onEndPoll && ( {i18n('icu:Poll__end-poll')} )} {onForward && ( {i18n('icu:MessageContextMenu__forward')} )} {onEdit && ( {i18n('icu:edit')} )} {onSelect && ( {i18n('icu:MessageContextMenu__select')} )} {onCopy && ( {i18n('icu:copy')} )} {isPinnedMessagesReceiveEnabled() && onPinMessage && ( {i18n('icu:MessageContextMenu__PinMessage')} )} {onMoreInfo && ( {i18n('icu:MessageContextMenu__info')} )} {onDeleteMessage && ( {i18n('icu:MessageContextMenu__deleteMessage')} )} {onRetryMessageSend && ( {i18n('icu:retrySend')} )} {onRetryDeleteForEveryone && ( {i18n('icu:retryDeleteForEveryone')} )} ); }