Convert handleExportResults to use createSingleSelectionCommand

This commit is contained in:
Robert
2023-04-20 17:35:47 +01:00
parent a6a2f9776a
commit dbf3f26d13
2 changed files with 9 additions and 24 deletions

View File

@@ -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);
}
/**

View File

@@ -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", () => {