// Copyright 2020-2022 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; import { ConversationDetailsIcon, IconType } from './ConversationDetailsIcon'; import { SignalService as Proto } from '../../../protobuf'; import type { ConversationType } from '../../../state/ducks/conversations'; import type { LocalizerType } from '../../../types/Util'; import { PanelRow } from './PanelRow'; import { PanelSection } from './PanelSection'; import { Select } from '../../Select'; import { useDelayedRestoreFocus } from '../../../hooks/useRestoreFocus'; import { useUniqueId } from '../../../hooks/useUniqueId'; const AccessControlEnum = Proto.AccessControl.AccessRequired; export type PropsType = { changeHasGroupLink: (value: boolean) => void; conversation?: ConversationType; copyGroupLink: (groupLink: string) => void; generateNewGroupLink: () => void; i18n: LocalizerType; isAdmin: boolean; setAccessControlAddFromInviteLinkSetting: (value: boolean) => void; }; export const GroupLinkManagement: React.ComponentType = ({ changeHasGroupLink, conversation, copyGroupLink, generateNewGroupLink, i18n, isAdmin, setAccessControlAddFromInviteLinkSetting, }) => { const groupLinkSelectId = useUniqueId(); const approveSelectId = useUniqueId(); if (conversation === undefined) { throw new Error('GroupLinkManagement rendered without a conversation'); } const [focusRef] = useDelayedRestoreFocus(); const createEventHandler = (handleEvent: (x: boolean) => void) => { return (value: string) => { handleEvent(value === 'true'); }; }; const membersNeedAdminApproval = conversation.accessControlAddFromInviteLink === AccessControlEnum.ADMINISTRATOR; const hasGroupLink = conversation.groupLink && conversation.accessControlAddFromInviteLink !== AccessControlEnum.UNSATISFIABLE; const groupLinkInfo = hasGroupLink ? conversation.groupLink : ''; return ( <> {i18n('ConversationDetails--group-link')} } right={ isAdmin ? ( } /> ) : null} ) : null} ); };