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

77 lines
1.7 KiB
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2018 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 = {
toggleSafetyNumberModal: (id: string) => void;
};
export type Props = PropsData & PropsHousekeeping & PropsActions;
2022-11-18 00:45:19 +00:00
export function SafetyNumberNotification({
2020-09-14 19:51:27 +00:00
contact,
isGroup,
i18n,
toggleSafetyNumberModal,
2022-11-18 00:45:19 +00:00
}: Props): JSX.Element {
const name = (
<span
key="external-1"
className="module-safety-number-notification__contact"
>
<ContactName
title={contact.title}
module="module-safety-number-notification__contact"
/>
</span>
);
2020-09-14 19:51:27 +00:00
return (
<SystemMessage
icon="safety-number"
contents={
isGroup ? (
<Intl
2023-03-30 00:03:25 +00:00
id="icu:safetyNumberChangedGroup"
components={{ name }}
i18n={i18n}
/>
) : (
<Intl id="icu:safetyNumberChanged" i18n={i18n} />
)
}
button={
2021-08-26 20:51:55 +00:00
<Button
onClick={() => {
toggleSafetyNumberModal(contact.id);
2021-08-26 20:51:55 +00:00
}}
size={ButtonSize.Small}
variant={ButtonVariant.SystemMessage}
>
{i18n('icu:SafetyNumberNotification__viewSafetyNumber')}
2021-08-26 20:51:55 +00:00
</Button>
}
/>
2020-09-14 19:51:27 +00:00
);
2022-11-18 00:45:19 +00:00
}