Signal-Desktop/ts/components/ErrorModal.tsx

52 lines
1.2 KiB
TypeScript
Raw Normal View History

// 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';
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 = {
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 (
<Modal
2022-09-29 16:34:38 +00:00
modalName="ErrorModal"
2020-10-06 17:06:34 +00:00
i18n={i18n}
onClose={onClose}
title={title || i18n('ErrorModal--title')}
2020-10-06 17:06:34 +00:00
>
<>
<div className="module-error-modal__description">
{description || i18n('ErrorModal--description')}
</div>
<Modal.ButtonFooter>
<Button
onClick={onClose}
ref={focusRef}
variant={ButtonVariant.Secondary}
>
{buttonText || i18n('Confirmation--confirm')}
</Button>
</Modal.ButtonFooter>
</>
</Modal>
2020-10-06 17:06:34 +00:00
);
};