Convert handleExportResults to use createSingleSelectionCommand
This commit is contained in:
@@ -279,7 +279,10 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
"codeQLQueryHistory.cancel": createMultiSelectionCommand(
|
||||
this.handleCancel.bind(this),
|
||||
),
|
||||
"codeQLQueryHistory.exportResults": this.handleExportResults.bind(this),
|
||||
"codeQLQueryHistory.exportResults": createSingleSelectionCommand(
|
||||
this.handleExportResults.bind(this),
|
||||
"query",
|
||||
),
|
||||
"codeQLQueryHistory.viewCsvResults": createSingleSelectionCommand(
|
||||
this.handleViewCsvResults.bind(this),
|
||||
"query",
|
||||
@@ -934,21 +937,12 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
);
|
||||
}
|
||||
|
||||
async handleExportResults(
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
): Promise<void> {
|
||||
// Variant analysis only
|
||||
if (
|
||||
!this.assertSingleQuery(multiSelect) ||
|
||||
singleItem.t !== "variant-analysis"
|
||||
) {
|
||||
async handleExportResults(item: QueryHistoryInfo): Promise<void> {
|
||||
if (item.t !== "variant-analysis") {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.variantAnalysisManager.exportResults(
|
||||
singleItem.variantAnalysis.id,
|
||||
);
|
||||
await this.variantAnalysisManager.exportResults(item.variantAnalysis.id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -726,7 +726,7 @@ describe("QueryHistoryManager", () => {
|
||||
queryHistoryManager = await createMockQueryHistory(localQueryHistory);
|
||||
|
||||
const item = localQueryHistory[4];
|
||||
await queryHistoryManager.handleExportResults(item, [item]);
|
||||
await queryHistoryManager.handleExportResults(item);
|
||||
|
||||
expect(variantAnalysisManagerStub.exportResults).not.toBeCalled();
|
||||
});
|
||||
@@ -735,20 +735,11 @@ describe("QueryHistoryManager", () => {
|
||||
queryHistoryManager = await createMockQueryHistory(allHistory);
|
||||
|
||||
const item = variantAnalysisHistory[1];
|
||||
await queryHistoryManager.handleExportResults(item, [item]);
|
||||
await queryHistoryManager.handleExportResults(item);
|
||||
expect(variantAnalysisManagerStub.exportResults).toBeCalledWith(
|
||||
item.variantAnalysis.id,
|
||||
);
|
||||
});
|
||||
|
||||
it("should not export results for multiple variant analyses", async () => {
|
||||
queryHistoryManager = await createMockQueryHistory(allHistory);
|
||||
|
||||
const item1 = variantAnalysisHistory[1];
|
||||
const item2 = variantAnalysisHistory[3];
|
||||
await queryHistoryManager.handleExportResults(item1, [item1, item2]);
|
||||
expect(variantAnalysisManagerStub.exportResults).not.toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Local Queries", () => {
|
||||
|
||||
Reference in New Issue
Block a user