Skip to content

Commit fa1f355

Browse files
committed
Show dialog with "Are you sure?" for in-progress queries
When you attempt to delete a query that's still in progress from your query history, you get a prompt asking if you're sure. If you pick "Yes", the item is removed and you see a toast notification with a link towards the GitHub Action.
1 parent 4cb3c4c commit fa1f355

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

extensions/ql-vscode/src/query-history.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
showAndLogInformationMessage,
2424
showAndLogWarningMessage,
2525
showBinaryChoiceDialog,
26+
showInformationMessageWithAction,
2627
} from "./helpers";
2728
import { extLogger } from "./common";
2829
import { URLSearchParams } from "url";
@@ -946,19 +947,45 @@ export class QueryHistoryManager extends DisposableObject {
946947
): Promise<void> {
947948
// We can remove a Variant Analysis locally, but not remotely.
948949
// The user must cancel the query on GitHub Actions explicitly.
950+
if (item.status === QueryStatus.InProgress) {
951+
const response = await showBinaryChoiceDialog(
952+
`You are about to delete this query: ${this.labelProvider.getLabel(
953+
item,
954+
)}. Are you sure?`,
955+
);
956+
if (!response) return;
957+
}
958+
949959
this.treeDataProvider.remove(item);
950960
void extLogger.log(`Deleted ${this.labelProvider.getLabel(item)}.`);
961+
951962
if (item.status === QueryStatus.InProgress) {
952-
void extLogger.log(
953-
"The variant analysis is still running on GitHub Actions. To cancel there, you must go to the workflow run in your browser.",
954-
);
963+
await this.showToastWithWorkflowRunLink(item);
955964
}
956965

957966
await this.variantAnalysisManager.removeVariantAnalysis(
958967
item.variantAnalysis,
959968
);
960969
}
961970

971+
private async showToastWithWorkflowRunLink(
972+
item: VariantAnalysisHistoryItem,
973+
): Promise<void> {
974+
void extLogger.log(
975+
"The variant analysis is still running on GitHub Actions. To cancel there, you must go to the workflow run in your browser.",
976+
);
977+
978+
const workflowRunUrl = getActionsWorkflowRunUrl(item);
979+
const message = `Remote query has been removed from history. However, the variant analysis is still running on GitHub Actions. To cancel it, you must go to the [workflow run](${workflowRunUrl}) in your browser.`;
980+
981+
void showInformationMessageWithAction(message, "Go to workflow run").then(
982+
async (shouldOpenWorkflowRun) => {
983+
if (!shouldOpenWorkflowRun) return;
984+
await env.openExternal(Uri.parse(workflowRunUrl));
985+
},
986+
);
987+
}
988+
962989
async handleSortByName() {
963990
if (this.treeDataProvider.sortOrder === SortOrder.NameAsc) {
964991
this.treeDataProvider.sortOrder = SortOrder.NameDesc;

0 commit comments

Comments
 (0)