Convert handleCopyRepoList to use createSingleSelectionCommand
This commit is contained in:
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user