Mark progress bars as cancellable where it appears we are respecting the token

This commit is contained in:
Robert
2024-03-26 17:03:57 +00:00
parent 5d45a114be
commit 6b0f7e86fa
4 changed files with 54 additions and 47 deletions

View File

@@ -673,6 +673,7 @@ export class DatabaseUI extends DisposableObject {
}, },
{ {
title: "Clearing cache", title: "Clearing cache",
cancellable: true,
}, },
); );
} }
@@ -692,6 +693,7 @@ export class DatabaseUI extends DisposableObject {
}, },
{ {
title: "Trimming cache", title: "Trimming cache",
cancellable: true,
}, },
); );
} }

View File

@@ -203,6 +203,7 @@ function getCommands(
}, },
{ {
title: "Restarting Query Server", title: "Restarting Query Server",
cancellable: true,
}, },
); );

View File

@@ -810,57 +810,60 @@ export class ModelEditorView extends AbstractWebview<
} }
private async modelDependency(): Promise<void> { private async modelDependency(): Promise<void> {
return withProgress(async (progress, token) => { return withProgress(
const addedDatabase = async (progress, token) => {
await this.promptChooseNewOrExistingDatabase(progress); const addedDatabase =
if (!addedDatabase || token.isCancellationRequested) { await this.promptChooseNewOrExistingDatabase(progress);
return; if (!addedDatabase || token.isCancellationRequested) {
} return;
}
const addedDbUri = addedDatabase.databaseUri.toString(); const addedDbUri = addedDatabase.databaseUri.toString();
if (this.modelingStore.isDbOpen(addedDbUri)) { if (this.modelingStore.isDbOpen(addedDbUri)) {
this.modelingEvents.fireFocusModelEditorEvent(addedDbUri); this.modelingEvents.fireFocusModelEditorEvent(addedDbUri);
return; return;
} }
const modelFile = await pickExtensionPack( const modelFile = await pickExtensionPack(
this.cliServer, this.cliServer,
addedDatabase, addedDatabase,
this.modelConfig, this.modelConfig,
this.app.logger, this.app.logger,
progress, progress,
token, token,
3, 3,
); );
if (!modelFile) { if (!modelFile) {
return; return;
} }
// Check again just before opening the editor to ensure no model editor has been opened between // Check again just before opening the editor to ensure no model editor has been opened between
// our first check and now. // our first check and now.
if (this.modelingStore.isDbOpen(addedDbUri)) { if (this.modelingStore.isDbOpen(addedDbUri)) {
this.modelingEvents.fireFocusModelEditorEvent(addedDbUri); this.modelingEvents.fireFocusModelEditorEvent(addedDbUri);
return; return;
} }
const view = new ModelEditorView( const view = new ModelEditorView(
this.app, this.app,
this.modelingStore, this.modelingStore,
this.modelingEvents, this.modelingEvents,
this.modelConfig, this.modelConfig,
this.databaseManager, this.databaseManager,
this.variantAnalysisManager, this.variantAnalysisManager,
this.cliServer, this.cliServer,
this.queryRunner, this.queryRunner,
this.queryStorageDir, this.queryStorageDir,
this.queryDir, this.queryDir,
addedDatabase, addedDatabase,
modelFile, modelFile,
this.language, this.language,
Mode.Framework, Mode.Framework,
); );
await view.openView(); await view.openView();
}); },
{ cancellable: true },
);
} }
private async promptChooseNewOrExistingDatabase( private async promptChooseNewOrExistingDatabase(

View File

@@ -125,6 +125,7 @@ export class QueryServerClient extends DisposableObject {
this.restartQueryServerInternal(progress, token), this.restartQueryServerInternal(progress, token),
{ {
title: "Restarting CodeQL query server due to unexpected termination", title: "Restarting CodeQL query server due to unexpected termination",
cancellable: true,
}, },
); );
} else { } else {