// Copyright 2024 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import type { ReactNode } from 'react'; import React, { useMemo, useState } from 'react'; import { v4 as generateUuid } from 'uuid'; import { Modal } from './Modal'; import type { LocalizerType } from '../types/I18N'; import type { CallLinkRestrictions } from '../types/CallLink'; import { type CallLinkType } from '../types/CallLink'; import { linkCallRoute } from '../util/signalRoutes'; import { Button, ButtonSize, ButtonVariant } from './Button'; import { Avatar, AvatarSize } from './Avatar'; import { getColorForCallLink } from '../util/getColorForCallLink'; import { CallLinkRestrictionsSelect } from './CallLinkRestrictionsSelect'; import { InAnotherCallTooltip } from './conversation/InAnotherCallTooltip'; const CallLinkEditModalRowIconClasses = { Edit: 'CallLinkEditModal__RowIcon--Edit', Approve: 'CallLinkEditModal__RowIcon--Approve', Copy: 'CallLinkEditModal__RowIcon--Copy', Share: 'CallLinkEditModal__RowIcon--Share', } as const; function RowIcon({ icon, }: { icon: keyof typeof CallLinkEditModalRowIconClasses; }) { return ( ); } function RowText({ children }: { children: ReactNode }) { return
{children}
; } function Row({ children }: { children: ReactNode }) { return
{children}
; } function RowButton({ onClick, children, }: { onClick: () => void; children: ReactNode; }) { return ( ); } function Hr() { return
; } export type CallLinkEditModalProps = { i18n: LocalizerType; callLink: CallLinkType; hasActiveCall: boolean; onClose: () => void; onCopyCallLink: () => void; onOpenCallLinkAddNameModal: () => void; onUpdateCallLinkRestrictions: (restrictions: CallLinkRestrictions) => void; onShareCallLinkViaSignal: () => void; onStartCallLinkLobby: () => void; }; export function CallLinkEditModal({ i18n, callLink, hasActiveCall, onClose, onCopyCallLink, onOpenCallLinkAddNameModal, onUpdateCallLinkRestrictions, onShareCallLinkViaSignal, onStartCallLinkLobby, }: CallLinkEditModalProps): JSX.Element { const [restrictionsId] = useState(() => generateUuid()); const callLinkWebUrl = useMemo(() => { return linkCallRoute.toWebUrl({ key: callLink.rootKey }).toString(); }, [callLink.rootKey]); const joinButton = ( ); return ( {i18n('icu:done')} } onClose={onClose} >
{callLink.name === '' ? i18n('icu:calling__call-link-default-title') : callLink.name}
{hasActiveCall ? ( {joinButton} ) : ( joinButton )}

{callLink.name === '' ? i18n('icu:CallLinkEditModal__AddCallNameLabel') : i18n('icu:CallLinkEditModal__EditCallNameLabel')}
{i18n('icu:CallLinkDetails__CopyLink')} {i18n('icu:CallLinkDetails__ShareLinkViaSignal')}
); }