signal-desktop/ts/components/ErrorModal.tsx

51 lines
1.1 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 { 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
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.Footer>
<Button
onClick={onClose}
ref={focusRef}
variant={ButtonVariant.Secondary}
>
{buttonText || i18n('Confirmation--confirm')}
</Button>
</Modal.Footer>
</>
</Modal>
2020-10-06 17:06:34 +00:00
);
};