signal-desktop/ts/components/ErrorModal.tsx

47 lines
1 KiB
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2020 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
2020-10-06 17:06:34 +00:00
import * as React from 'react';
import type { LocalizerType } from '../types/Util';
import { Modal } from './Modal';
import { Button, ButtonVariant } from './Button';
2020-10-06 17:06:34 +00:00
export type PropsType = {
description?: string;
title?: string;
2020-10-06 17:06:34 +00:00
onClose: () => void;
i18n: LocalizerType;
};
function focusRef(el: HTMLElement | null) {
if (el) {
el.focus();
}
}
2022-11-18 00:45:19 +00:00
export function ErrorModal(props: PropsType): JSX.Element {
2022-12-22 03:07:45 +00:00
const { description, i18n, onClose, title } = props;
2020-10-06 17:06:34 +00:00
const footer = (
<Button onClick={onClose} ref={focusRef} variant={ButtonVariant.Secondary}>
2022-12-22 03:07:45 +00:00
{i18n('Confirmation--confirm')}
</Button>
);
2020-10-06 17:06:34 +00:00
return (
<Modal
2022-09-27 20:24:21 +00:00
modalName="ErrorModal"
2020-10-06 17:06:34 +00:00
i18n={i18n}
onClose={onClose}
title={title || i18n('ErrorModal--title')}
modalFooter={footer}
2020-10-06 17:06:34 +00:00
>
<div className="module-error-modal__description">
{description || i18n('ErrorModal--description')}
</div>
</Modal>
2020-10-06 17:06:34 +00:00
);
2022-11-18 00:45:19 +00:00
}