signal-desktop/ts/components/ErrorModal.tsx

50 lines
1.2 KiB
TypeScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2020 Signal Messenger, LLC
// 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 { ConfirmationModal } from './ConfirmationModal';
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 (
<ConfirmationModal
actions={[]}
title={title || i18n('ErrorModal--title')}
i18n={i18n}
onClose={onClose}
>
<div className="module-error-modal__description">
{description || i18n('ErrorModal--description')}
</div>
<div className="module-error-modal__button-container">
<button
type="button"
className="module-confirmation-dialog__container__buttons__button"
onClick={onClose}
ref={focusRef}
>
2020-11-20 17:30:45 +00:00
{buttonText || i18n('Confirmation--confirm')}
2020-10-06 17:06:34 +00:00
</button>
</div>
</ConfirmationModal>
);
};