// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React, { ReactNode } from 'react'; import classNames from 'classnames'; import { LocalizerType } from '../../../types/Util'; import { ConfirmationDialog } from '../../ConfirmationDialog'; import { Tooltip, TooltipPlacement } from '../../Tooltip'; import { PanelRow } from './PanelRow'; import { PanelSection } from './PanelSection'; import { ConversationDetailsIcon } from './ConversationDetailsIcon'; export type Props = { cannotLeaveBecauseYouAreLastAdmin: boolean; conversationTitle: string; left: boolean; onBlock: () => void; onLeave: () => void; i18n: LocalizerType; }; export const ConversationDetailsActions: React.ComponentType = ({ cannotLeaveBecauseYouAreLastAdmin, conversationTitle, left, onBlock, onLeave, i18n, }) => { const [confirmingLeave, setConfirmingLeave] = React.useState(false); const [confirmingBlock, setConfirmingBlock] = React.useState(false); let leaveGroupNode: ReactNode; let blockGroupNode: ReactNode; if (!left) { leaveGroupNode = ( setConfirmingLeave(true)} icon={ } label={
{i18n('ConversationDetailsActions--leave-group')}
} /> ); if (cannotLeaveBecauseYouAreLastAdmin) { leaveGroupNode = ( {leaveGroupNode} ); } } blockGroupNode = ( setConfirmingBlock(true)} icon={ } label={
{i18n('ConversationDetailsActions--block-group')}
} /> ); if (cannotLeaveBecauseYouAreLastAdmin) { blockGroupNode = ( {blockGroupNode} ); } return ( <> {leaveGroupNode} {blockGroupNode} {confirmingLeave && ( setConfirmingLeave(false)} title={i18n('ConversationDetailsActions--leave-group-modal-title')} > {i18n('ConversationDetailsActions--leave-group-modal-content')} )} {confirmingBlock && ( setConfirmingBlock(false)} title={i18n('ConversationDetailsActions--block-group-modal-title', [ conversationTitle, ])} > {i18n('ConversationDetailsActions--block-group-modal-content')} )} ); };