// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React 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; onBlock: () => void; onLeave: () => void; i18n: LocalizerType; }; export const ConversationDetailsActions: React.ComponentType = ({ cannotLeaveBecauseYouAreLastAdmin, conversationTitle, onBlock, onLeave, i18n, }) => { const [confirmingLeave, setConfirmingLeave] = React.useState(false); const [confirmingBlock, setConfirmingBlock] = React.useState(false); let leaveGroupNode = ( setConfirmingLeave(true)} icon={ } label={
{i18n('ConversationDetailsActions--leave-group')}
} /> ); if (cannotLeaveBecauseYouAreLastAdmin) { leaveGroupNode = ( {leaveGroupNode} ); } return ( <> {leaveGroupNode} setConfirmingBlock(true)} icon={ } label={
{i18n('ConversationDetailsActions--block-group')}
} />
{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')} )} ); };