Keep bulk migration open when aborting during execution
This commit is contained in:
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- (**Migration**) Show "abort" button during active bulk migration search
|
- (**Migration**) Show "abort" button during active bulk migration search
|
||||||
|
- (**Migration**) Keep the migration page open when aborting during the actual migration execution
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ export const DEFAULT_MIGRATION_STATE: MigrationState = {
|
|||||||
startedAt: null,
|
startedAt: null,
|
||||||
lastUpdatedAt: null,
|
lastUpdatedAt: null,
|
||||||
groupExpandState: {},
|
groupExpandState: {},
|
||||||
|
isAborted: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ENTRY_STATUS_TRANSLATION: Record<MigrationEntryStatus, MessageDescriptor> = {
|
export const ENTRY_STATUS_TRANSLATION: Record<MigrationEntryStatus, MessageDescriptor> = {
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ export interface MigrationState {
|
|||||||
startedAt: number | null;
|
startedAt: number | null;
|
||||||
lastUpdatedAt: number | null;
|
lastUpdatedAt: number | null;
|
||||||
groupExpandState: Partial<Record<MigrationEntryStatus, boolean>>;
|
groupExpandState: Partial<Record<MigrationEntryStatus, boolean>>;
|
||||||
|
isAborted: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SourceItem extends SourceIdInfo, SourceNameInfo, SourceLanguageInfo, SourceIconInfo, SourceMetaInfo {}
|
export interface SourceItem extends SourceIdInfo, SourceNameInfo, SourceLanguageInfo, SourceIconInfo, SourceMetaInfo {}
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ export class MigrationManager {
|
|||||||
);
|
);
|
||||||
case MigrationPhase.MIGRATING:
|
case MigrationPhase.MIGRATING:
|
||||||
return (
|
return (
|
||||||
|
MigrationManager.getState().isAborted ||
|
||||||
MigrationManager.getState().migrationProgress.completed ===
|
MigrationManager.getState().migrationProgress.completed ===
|
||||||
MigrationManager.getState().migrationProgress.total
|
MigrationManager.getState().migrationProgress.total
|
||||||
);
|
);
|
||||||
@@ -470,13 +471,27 @@ export class MigrationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async abort(reason: unknown = 'abort'): Promise<boolean> {
|
static async stop(reason: unknown = 'stopped'): Promise<boolean> {
|
||||||
if (!(await MigrationManager.confirmAbort())) {
|
if (!(await MigrationManager.confirmAbort())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MigrationManager.abortAndResetAbortController(reason);
|
MigrationManager.abortAndResetAbortController(reason);
|
||||||
|
|
||||||
|
MigrationManager.updateState((draft) => {
|
||||||
|
draft.isAborted = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async abort(reason: unknown = 'abort'): Promise<boolean> {
|
||||||
|
if (!MigrationManager.getState().isAborted && !(await MigrationManager.confirmAbort())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MigrationManager.abortAndResetAbortController(reason);
|
||||||
|
|
||||||
MigrationManager.reset();
|
MigrationManager.reset();
|
||||||
|
|
||||||
ReactRouter.navigate(AppRoutes.browse.path(BrowseTab.MIGRATE));
|
ReactRouter.navigate(AppRoutes.browse.path(BrowseTab.MIGRATE));
|
||||||
|
|||||||
@@ -23,9 +23,21 @@ export const MigrationExecute = () => {
|
|||||||
const entries = MigrationManager.useEntries();
|
const entries = MigrationManager.useEntries();
|
||||||
const progress = MigrationManager.useMigrationProgress();
|
const progress = MigrationManager.useMigrationProgress();
|
||||||
|
|
||||||
useAppTitleAndAction(MigrationManager.isPhaseComplete() ? t`Migration complete` : t`Migrating`, undefined, [
|
useAppTitleAndAction(
|
||||||
MigrationManager.isPhaseComplete(),
|
(() => {
|
||||||
]);
|
if (MigrationManager.getState().isAborted) {
|
||||||
|
return t`Aborted`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MigrationManager.isPhaseComplete()) {
|
||||||
|
return t`Migration complete`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return t`Migrating`;
|
||||||
|
})(),
|
||||||
|
undefined,
|
||||||
|
[MigrationManager.isPhaseComplete()],
|
||||||
|
);
|
||||||
|
|
||||||
const entryList = useMemo(() => Object.values(entries), [entries]);
|
const entryList = useMemo(() => Object.values(entries), [entries]);
|
||||||
const migratingEntries = useMemo(
|
const migratingEntries = useMemo(
|
||||||
@@ -140,7 +152,7 @@ export const MigrationExecute = () => {
|
|||||||
<MigrationContinueButton
|
<MigrationContinueButton
|
||||||
title={MigrationManager.isPhaseComplete() ? t`Done` : t`Abort`}
|
title={MigrationManager.isPhaseComplete() ? t`Done` : t`Abort`}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
MigrationManager.isPhaseComplete() ? MigrationManager.reset() : MigrationManager.abort()
|
MigrationManager.isPhaseComplete() ? MigrationManager.reset() : MigrationManager.stop()
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -333,6 +333,10 @@ msgstr "Abort"
|
|||||||
msgid "Abort migration"
|
msgid "Abort migration"
|
||||||
msgstr "Abort migration"
|
msgstr "Abort migration"
|
||||||
|
|
||||||
|
#: src/features/migration/screens/MigrationExecute.tsx
|
||||||
|
msgid "Aborted"
|
||||||
|
msgstr "Aborted"
|
||||||
|
|
||||||
#: src/features/navigation-bar/NavigationBar.constants.ts
|
#: src/features/navigation-bar/NavigationBar.constants.ts
|
||||||
#: src/features/settings/screens/About.tsx
|
#: src/features/settings/screens/About.tsx
|
||||||
msgid "About"
|
msgid "About"
|
||||||
|
|||||||
Reference in New Issue
Block a user