Retry dialog for errors during backup download
This commit is contained in:
parent
6e1fd5958e
commit
12f28448b2
6 changed files with 202 additions and 11 deletions
|
@ -18,16 +18,21 @@ export type PropsType = Readonly<{
|
|||
i18n: LocalizerType;
|
||||
currentBytes?: number;
|
||||
totalBytes?: number;
|
||||
hasError?: boolean;
|
||||
onCancel: () => void;
|
||||
onRetry: () => void;
|
||||
}>;
|
||||
|
||||
export function InstallScreenBackupImportStep({
|
||||
i18n,
|
||||
currentBytes,
|
||||
totalBytes,
|
||||
hasError,
|
||||
onCancel,
|
||||
onRetry,
|
||||
}: PropsType): JSX.Element {
|
||||
const [isConfirmingCancel, setIsConfirmingCancel] = useState(false);
|
||||
const [isConfirmingSkip, setIsConfirmingSkip] = useState(false);
|
||||
|
||||
const confirmCancel = useCallback(() => {
|
||||
setIsConfirmingCancel(true);
|
||||
|
@ -42,6 +47,24 @@ export function InstallScreenBackupImportStep({
|
|||
setIsConfirmingCancel(false);
|
||||
}, [onCancel]);
|
||||
|
||||
const confirmSkip = useCallback(() => {
|
||||
setIsConfirmingSkip(true);
|
||||
}, []);
|
||||
|
||||
const abortSkip = useCallback(() => {
|
||||
setIsConfirmingSkip(false);
|
||||
}, []);
|
||||
|
||||
const onSkipWrap = useCallback(() => {
|
||||
onCancel();
|
||||
setIsConfirmingSkip(false);
|
||||
}, [onCancel]);
|
||||
|
||||
const onRetryWrap = useCallback(() => {
|
||||
onRetry();
|
||||
setIsConfirmingSkip(false);
|
||||
}, [onRetry]);
|
||||
|
||||
let progress: JSX.Element;
|
||||
let isCancelPossible = true;
|
||||
if (currentBytes != null && totalBytes != null) {
|
||||
|
@ -79,6 +102,7 @@ export function InstallScreenBackupImportStep({
|
|||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="InstallScreenBackupImportStep">
|
||||
<TitlebarDragArea />
|
||||
|
@ -127,6 +151,44 @@ export function InstallScreenBackupImportStep({
|
|||
{i18n('icu:BackupImportScreen__cancel-confirmation__body')}
|
||||
</ConfirmationDialog>
|
||||
)}
|
||||
|
||||
{isConfirmingSkip && (
|
||||
<ConfirmationDialog
|
||||
dialogName="InstallScreenBackupImportStep.confirmSkip"
|
||||
title={i18n('icu:BackupImportScreen__skip-confirmation__title')}
|
||||
cancelText={i18n('icu:BackupImportScreen__skip-confirmation__cancel')}
|
||||
actions={[
|
||||
{
|
||||
action: onSkipWrap,
|
||||
style: 'affirmative',
|
||||
text: i18n('icu:BackupImportScreen__skip'),
|
||||
},
|
||||
]}
|
||||
i18n={i18n}
|
||||
onClose={abortSkip}
|
||||
>
|
||||
{i18n('icu:BackupImportScreen__skip-confirmation__body')}
|
||||
</ConfirmationDialog>
|
||||
)}
|
||||
|
||||
{hasError && !isConfirmingSkip && (
|
||||
<ConfirmationDialog
|
||||
dialogName="InstallScreenBackupImportStep.error"
|
||||
title={i18n('icu:BackupImportScreen__error__title')}
|
||||
cancelText={i18n('icu:BackupImportScreen__skip')}
|
||||
actions={[
|
||||
{
|
||||
action: onRetryWrap,
|
||||
style: 'affirmative',
|
||||
text: i18n('icu:BackupImportScreen__error__confirm'),
|
||||
},
|
||||
]}
|
||||
i18n={i18n}
|
||||
onClose={confirmSkip}
|
||||
>
|
||||
{i18n('icu:BackupImportScreen__error__body')}
|
||||
</ConfirmationDialog>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue