signal-desktop/ts/components/conversation/SafetyNumberNotification.tsx

76 lines
1.6 KiB
TypeScript
Raw Normal View History

// Copyright 2018-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
2021-08-26 20:51:55 +00:00
import { Button, ButtonSize, ButtonVariant } from '../Button';
import { SystemMessage } from './SystemMessage';
import { ContactName } from './ContactName';
import { Intl } from '../Intl';
import type { LocalizerType } from '../../types/Util';
export type ContactType = {
id: string;
2020-07-24 01:35:32 +00:00
title: string;
};
export type PropsData = {
isGroup: boolean;
contact: ContactType;
};
type PropsHousekeeping = {
2019-01-14 21:49:58 +00:00
i18n: LocalizerType;
};
export type PropsActions = {
showIdentity: (id: string) => void;
};
export type Props = PropsData & PropsHousekeeping & PropsActions;
2020-09-14 19:51:27 +00:00
export const SafetyNumberNotification = ({
contact,
isGroup,
i18n,
showIdentity,
}: Props): JSX.Element => {
const changeKey = isGroup
? 'safetyNumberChangedGroup'
: 'safetyNumberChanged';
2020-09-14 19:51:27 +00:00
return (
<SystemMessage
icon="safety-number"
contents={
<Intl
id={changeKey}
components={[
<span
key="external-1"
className="module-safety-number-notification__contact"
>
<ContactName
title={contact.title}
module="module-safety-number-notification__contact"
/>
</span>,
]}
i18n={i18n}
/>
}
button={
2021-08-26 20:51:55 +00:00
<Button
onClick={() => {
showIdentity(contact.id);
}}
size={ButtonSize.Small}
variant={ButtonVariant.SystemMessage}
>
{i18n('verifyNewNumber')}
</Button>
}
/>
2020-09-14 19:51:27 +00:00
);
};