// Copyright 2020 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; import { ConversationDetailsIcon } from './ConversationDetailsIcon'; import { SignalService as Proto } from '../../../protobuf'; import { ConversationType } from '../../../state/ducks/conversations'; import { LocalizerType } from '../../../types/Util'; import { PanelRow } from './PanelRow'; import { PanelSection } from './PanelSection'; import { Select } from '../../Select'; 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, }) => { if (conversation === undefined) { throw new Error('GroupLinkManagement rendered without a conversation'); } 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 ( <> ) : null } /> {hasGroupLink ? ( <> } label={i18n('GroupLinkManagement--share')} onClick={() => { if (conversation.groupLink) { copyGroupLink(conversation.groupLink); } }} /> {isAdmin ? ( } label={i18n('GroupLinkManagement--reset')} onClick={generateNewGroupLink} /> ) : null} {isAdmin ? ( } /> ) : null} ) : null} ); };