// Copyright 2019-2020 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import * as React from 'react'; import classNames from 'classnames'; import { LocalizerType } from '../types/Util'; import { ConversationType } from '../state/ducks/conversations'; import { Avatar } from './Avatar'; import { sortByTitle } from '../util/sortByTitle'; export type ActionSpec = { text: string; action: () => unknown; style?: 'affirmative' | 'negative'; }; type CallbackType = () => unknown; export type DataPropsType = { readonly areWeInvited: boolean; readonly droppedMembers: Array; readonly hasMigrated: boolean; readonly invitedMembers: Array; readonly migrate: CallbackType; readonly onClose: CallbackType; }; export type HousekeepingPropsType = { readonly i18n: LocalizerType; }; export type PropsType = DataPropsType & HousekeepingPropsType; function focusRef(el: HTMLElement | null) { if (el) { el.focus(); } } export const GroupV1MigrationDialog = React.memo((props: PropsType) => { const { areWeInvited, droppedMembers, hasMigrated, i18n, invitedMembers, migrate, onClose, } = props; const title = hasMigrated ? i18n('GroupV1--Migration--info--title') : i18n('GroupV1--Migration--migrate--title'); const keepHistory = hasMigrated ? i18n('GroupV1--Migration--info--keep-history') : i18n('GroupV1--Migration--migrate--keep-history'); const migrationKey = hasMigrated ? 'after' : 'before'; const droppedMembersKey = `GroupV1--Migration--info--removed--${migrationKey}`; return (
); } return (
); } function renderMembers( members: Array, prefix: string, i18n: LocalizerType ): React.ReactElement | null { if (!members.length) { return null; } const postfix = members.length === 1 ? '--one' : '--many'; const key = `${prefix}${postfix}`; return (
{i18n(key)}
{sortByTitle(members).map(member => (
{' '} {member.title}
))}
); }