Skip to content

Commit a1f5e5b

Browse files
Merge pull request #1944 from github/elena/fix-removal
Display modal when removing an item from query history
2 parents 7b5e5a6 + c62f381 commit a1f5e5b

2 files changed

Lines changed: 284 additions & 75 deletions

File tree

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

Lines changed: 26 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";
@@ -951,19 +952,41 @@ export class QueryHistoryManager extends DisposableObject {
951952
): Promise<void> {
952953
// We can remove a Variant Analysis locally, but not remotely.
953954
// The user must cancel the query on GitHub Actions explicitly.
955+
if (item.status === QueryStatus.InProgress) {
956+
const response = await showBinaryChoiceDialog(
957+
`You are about to delete this query: ${this.labelProvider.getLabel(
958+
item,
959+
)}. Are you sure?`,
960+
);
961+
if (!response) return;
962+
}
963+
954964
this.treeDataProvider.remove(item);
955965
void extLogger.log(`Deleted ${this.labelProvider.getLabel(item)}.`);
966+
956967
if (item.status === QueryStatus.InProgress) {
957-
void extLogger.log(
958-
"The variant analysis is still running on GitHub Actions. To cancel there, you must go to the workflow run in your browser.",
959-
);
968+
await this.showToastWithWorkflowRunLink(item);
960969
}
961970

962971
await this.variantAnalysisManager.removeVariantAnalysis(
963972
item.variantAnalysis,
964973
);
965974
}
966975

976+
private async showToastWithWorkflowRunLink(
977+
item: VariantAnalysisHistoryItem,
978+
): Promise<void> {
979+
const workflowRunUrl = getActionsWorkflowRunUrl(item);
980+
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.`;
981+
982+
void showInformationMessageWithAction(message, "Go to workflow run").then(
983+
async (shouldOpenWorkflowRun) => {
984+
if (!shouldOpenWorkflowRun) return;
985+
await env.openExternal(Uri.parse(workflowRunUrl));
986+
},
987+
);
988+
}
989+
967990
async handleSortByName() {
968991
if (this.treeDataProvider.sortOrder === SortOrder.NameAsc) {
969992
this.treeDataProvider.sortOrder = SortOrder.NameDesc;

0 commit comments

Comments
 (0)