Convert handleCopyRepoList to use createSingleSelectionCommand

This commit is contained in:
Robert
2023-04-20 17:31:44 +01:00
parent be6f356437
commit a6a2f9776a
2 changed files with 9 additions and 22 deletions

View File

@@ -304,7 +304,10 @@ export class QueryHistoryManager extends DisposableObject {
this.handleOpenOnGithub.bind(this),
"query",
),
"codeQLQueryHistory.copyRepoList": this.handleCopyRepoList.bind(this),
"codeQLQueryHistory.copyRepoList": createSingleSelectionCommand(
this.handleCopyRepoList.bind(this),
"query",
),
"codeQL.exportSelectedVariantAnalysisResults":
this.exportSelectedVariantAnalysisResults.bind(this),
@@ -920,21 +923,14 @@ export class QueryHistoryManager extends DisposableObject {
);
}
async handleCopyRepoList(
singleItem: QueryHistoryInfo,
multiSelect: QueryHistoryInfo[] | undefined,
) {
// Variant analyses only
if (
!this.assertSingleQuery(multiSelect) ||
singleItem.t !== "variant-analysis"
) {
async handleCopyRepoList(item: QueryHistoryInfo) {
if (item.t !== "variant-analysis") {
return;
}
await this.app.commands.execute(
"codeQL.copyVariantAnalysisRepoList",
singleItem.variantAnalysis.id,
item.variantAnalysis.id,
);
}

View File

@@ -704,7 +704,7 @@ describe("QueryHistoryManager", () => {
queryHistoryManager = await createMockQueryHistory(localQueryHistory);
const item = localQueryHistory[4];
await queryHistoryManager.handleCopyRepoList(item, [item]);
await queryHistoryManager.handleCopyRepoList(item);
expect(executeCommand).not.toBeCalled();
});
@@ -713,21 +713,12 @@ describe("QueryHistoryManager", () => {
queryHistoryManager = await createMockQueryHistory(allHistory);
const item = variantAnalysisHistory[1];
await queryHistoryManager.handleCopyRepoList(item, [item]);
await queryHistoryManager.handleCopyRepoList(item);
expect(executeCommand).toBeCalledWith(
"codeQL.copyVariantAnalysisRepoList",
item.variantAnalysis.id,
);
});
it("should not copy repo list for multiple variant analyses", async () => {
queryHistoryManager = await createMockQueryHistory(allHistory);
const item1 = variantAnalysisHistory[1];
const item2 = variantAnalysisHistory[3];
await queryHistoryManager.handleCopyRepoList(item1, [item1, item2]);
expect(executeCommand).not.toBeCalled();
});
});
describe("handleExportResults", () => {