2021-04-13 14:20:02 +00:00
|
|
|
// Copyright 2020-2021 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';
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { LocalizerType } from '../types/Util';
|
2021-04-27 19:29:59 +00:00
|
|
|
import { Modal } from './Modal';
|
|
|
|
import { Button, ButtonVariant } from './Button';
|
2020-10-06 17:06:34 +00:00
|
|
|
|
|
|
|
export type PropsType = {
|
2021-01-29 22:16:48 +00:00
|
|
|
buttonText?: string;
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ErrorModal = (props: PropsType): JSX.Element => {
|
|
|
|
const { buttonText, description, i18n, onClose, title } = props;
|
|
|
|
|
|
|
|
return (
|
2021-04-27 19:29:59 +00:00
|
|
|
<Modal
|
2020-10-06 17:06:34 +00:00
|
|
|
i18n={i18n}
|
|
|
|
onClose={onClose}
|
2021-04-27 19:29:59 +00:00
|
|
|
title={title || i18n('ErrorModal--title')}
|
2020-10-06 17:06:34 +00:00
|
|
|
>
|
2021-04-27 19:29:59 +00:00
|
|
|
<>
|
|
|
|
<div className="module-error-modal__description">
|
|
|
|
{description || i18n('ErrorModal--description')}
|
|
|
|
</div>
|
2021-05-27 15:43:39 +00:00
|
|
|
<Modal.ButtonFooter>
|
2021-04-27 19:29:59 +00:00
|
|
|
<Button
|
|
|
|
onClick={onClose}
|
|
|
|
ref={focusRef}
|
|
|
|
variant={ButtonVariant.Secondary}
|
|
|
|
>
|
|
|
|
{buttonText || i18n('Confirmation--confirm')}
|
|
|
|
</Button>
|
2021-05-27 15:43:39 +00:00
|
|
|
</Modal.ButtonFooter>
|
2021-04-27 19:29:59 +00:00
|
|
|
</>
|
|
|
|
</Modal>
|
2020-10-06 17:06:34 +00:00
|
|
|
);
|
|
|
|
};
|