// Copyright 2020 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; import { ConversationDetailsIcon } from './ConversationDetailsIcon'; import { ConversationType } from '../../../state/ducks/conversations'; import { LocalizerType } from '../../../types/Util'; import { PanelRow } from './PanelRow'; import { PanelSection } from './PanelSection'; import { AccessControlClass } from '../../../textsecure.d'; export type PropsType = { accessEnum: typeof AccessControlClass.AccessRequired; 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 = ({ accessEnum, 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 (event: React.ChangeEvent) => { handleEvent(event.target.value === 'true'); }; }; const membersNeedAdminApproval = conversation.accessControlAddFromInviteLink === accessEnum.ADMINISTRATOR; const hasGroupLink = conversation.groupLink && conversation.accessControlAddFromInviteLink !== accessEnum.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} ); };