signal-desktop/ts/components/ErrorModal.tsx

47 lines
1 KiB
TypeScript
Raw Normal View History

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