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';
|
|
|
|
|
2021-10-26 14:15:33 -05:00
|
|
|
import type { LocalizerType } from '../types/Util';
|
2021-04-27 12:29:59 -07:00
|
|
|
import { Modal } from './Modal';
|
|
|
|
import { Button, ButtonVariant } from './Button';
|
2020-10-06 10:06:34 -07:00
|
|
|
|
|
|
|
export type PropsType = {
|
2024-02-22 13:19:50 -08:00
|
|
|
buttonVariant?: ButtonVariant;
|
2021-01-29 14:16:48 -08:00
|
|
|
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 {
|
2024-02-22 13:19:50 -08:00
|
|
|
const { buttonVariant, description, i18n, onClose, title } = props;
|
2020-10-06 10:06:34 -07:00
|
|
|
|
2022-09-29 16:40:09 -06:00
|
|
|
const footer = (
|
2024-02-22 13:19:50 -08:00
|
|
|
<Button
|
|
|
|
onClick={onClose}
|
|
|
|
ref={focusRef}
|
|
|
|
variant={buttonVariant || ButtonVariant.Secondary}
|
|
|
|
>
|
2023-03-29 17:03:25 -07:00
|
|
|
{i18n('icu:Confirmation--confirm')}
|
2022-09-29 16:40:09 -06:00
|
|
|
</Button>
|
|
|
|
);
|
|
|
|
|
2020-10-06 10:06:34 -07:00
|
|
|
return (
|
2021-04-27 12:29:59 -07:00
|
|
|
<Modal
|
2022-09-27 13:24:21 -07:00
|
|
|
modalName="ErrorModal"
|
2020-10-06 10:06:34 -07:00
|
|
|
i18n={i18n}
|
|
|
|
onClose={onClose}
|
2023-03-29 17:03:25 -07:00
|
|
|
title={title || i18n('icu:ErrorModal--title')}
|
2022-09-29 16:40:09 -06:00
|
|
|
modalFooter={footer}
|
2020-10-06 10:06:34 -07:00
|
|
|
>
|
2022-09-29 16:40:09 -06:00
|
|
|
<div className="module-error-modal__description">
|
2023-03-29 17:03:25 -07:00
|
|
|
{description || i18n('icu:ErrorModal--description')}
|
2022-09-29 16:40:09 -06:00
|
|
|
</div>
|
2021-04-27 12:29:59 -07:00
|
|
|
</Modal>
|
2020-10-06 10:06:34 -07:00
|
|
|
);
|
2022-11-17 16:45:19 -08:00
|
|
|
}
|