signal-desktop/ts/components/CrashReportDialog.tsx

74 lines
1.7 KiB
TypeScript
Raw Normal View History

2022-01-11 20:02:46 +00:00
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import type { LocalizerType } from '../types/Util';
import { Button, ButtonVariant } from './Button';
import { Modal } from './Modal';
import { Spinner } from './Spinner';
type PropsActionsType = {
uploadCrashReports: () => void;
eraseCrashReports: () => void;
};
type PropsType = {
i18n: LocalizerType;
isPending: boolean;
} & PropsActionsType;
export function CrashReportDialog(props: Readonly<PropsType>): JSX.Element {
const { i18n, isPending, uploadCrashReports, eraseCrashReports } = props;
const onEraseClick = (event: React.MouseEvent) => {
event.preventDefault();
eraseCrashReports();
};
const onSubmitClick = (event: React.MouseEvent) => {
event.preventDefault();
uploadCrashReports();
};
const footer = (
<>
<Button
disabled={isPending}
onClick={onEraseClick}
variant={ButtonVariant.Secondary}
>
2023-03-30 00:03:25 +00:00
{i18n('icu:CrashReportDialog__erase')}
</Button>
<Button
disabled={isPending}
onClick={onSubmitClick}
ref={button => button?.focus()}
variant={ButtonVariant.Primary}
>
{isPending ? (
<Spinner size="22px" svgSize="small" />
) : (
2023-03-30 00:03:25 +00:00
i18n('icu:CrashReportDialog__submit')
)}
</Button>
</>
);
2022-01-11 20:02:46 +00:00
return (
<Modal
2022-09-27 20:24:21 +00:00
modalName="CrashReportDialog"
2022-01-11 20:02:46 +00:00
moduleClassName="module-Modal--important"
i18n={i18n}
2023-03-30 00:03:25 +00:00
title={i18n('icu:CrashReportDialog__title')}
2022-01-11 20:02:46 +00:00
hasXButton
onClose={eraseCrashReports}
modalFooter={footer}
2022-01-11 20:02:46 +00:00
>
2023-03-30 00:03:25 +00:00
<section>{i18n('icu:CrashReportDialog__body')}</section>
2022-01-11 20:02:46 +00:00
</Modal>
);
}