Skip to content

Commit 1955086

Browse files
committed
Add new command and add it to db panel
1 parent d00624c commit 1955086

4 files changed

Lines changed: 31 additions & 2 deletions

File tree

extensions/ql-vscode/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,10 @@
516516
"title": "Add new list",
517517
"icon": "$(new-folder)"
518518
},
519+
{
520+
"command": "codeQLVariantAnalysisRepositories.importCodeSearch",
521+
"title": "Import Repos from GitHub Code Search"
522+
},
519523
{
520524
"command": "codeQLVariantAnalysisRepositories.setSelectedItem",
521525
"title": "Select"
@@ -961,6 +965,11 @@
961965
"when": "view == codeQLVariantAnalysisRepositories && viewItem =~ /canBeOpenedOnGitHub/",
962966
"group": "2_qlContextMenu@1"
963967
},
968+
{
969+
"command": "codeQLVariantAnalysisRepositories.importCodeSearch",
970+
"when": "view == codeQLVariantAnalysisRepositories && viewItem =~ /canImportCodeSearch/",
971+
"group": "2_qlContextMenu@1"
972+
},
964973
{
965974
"command": "codeQLDatabases.setCurrentDatabase",
966975
"group": "inline",
@@ -1297,6 +1306,10 @@
12971306
"command": "codeQLVariantAnalysisRepositories.removeItemContextMenu",
12981307
"when": "false"
12991308
},
1309+
{
1310+
"command": "codeQLVariantAnalysisRepositories.importCodeSearch",
1311+
"when": "false"
1312+
},
13001313
{
13011314
"command": "codeQLDatabases.setCurrentDatabase",
13021315
"when": "false"

extensions/ql-vscode/src/common/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ export type DatabasePanelCommands = {
275275
"codeQLVariantAnalysisRepositories.openOnGitHubContextMenu": TreeViewContextSingleSelectionCommandFunction<DbTreeViewItem>;
276276
"codeQLVariantAnalysisRepositories.renameItemContextMenu": TreeViewContextSingleSelectionCommandFunction<DbTreeViewItem>;
277277
"codeQLVariantAnalysisRepositories.removeItemContextMenu": TreeViewContextSingleSelectionCommandFunction<DbTreeViewItem>;
278+
"codeQLVariantAnalysisRepositories.importCodeSearch": TreeViewContextSingleSelectionCommandFunction<DbTreeViewItem>;
278279
};
279280

280281
export type AstCfgCommands = {

extensions/ql-vscode/src/databases/ui/db-panel.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ export class DbPanel extends DisposableObject {
9393
this.renameItem.bind(this),
9494
"codeQLVariantAnalysisRepositories.removeItemContextMenu":
9595
this.removeItem.bind(this),
96+
"codeQLVariantAnalysisRepositories.importCodeSearch":
97+
this.importCodeSearch.bind(this),
9698
};
9799
}
98100

@@ -323,6 +325,12 @@ export class DbPanel extends DisposableObject {
323325
await this.dbManager.removeDbItem(treeViewItem.dbItem);
324326
}
325327

328+
private async importCodeSearch(treeViewItem: DbTreeViewItem): Promise<void> {
329+
if (treeViewItem.dbItem === undefined) {
330+
throw new Error("Please select a valid list to add code search results.");
331+
}
332+
}
333+
326334
private async onDidCollapseElement(
327335
event: TreeViewExpansionEvent<DbTreeViewItem>,
328336
): Promise<void> {

extensions/ql-vscode/src/databases/ui/db-tree-view-item-action.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export type DbTreeViewItemAction =
44
| "canBeSelected"
55
| "canBeRemoved"
66
| "canBeRenamed"
7-
| "canBeOpenedOnGitHub";
7+
| "canBeOpenedOnGitHub"
8+
| "canImportCodeSearch";
89

910
export function getDbItemActions(dbItem: DbItem): DbTreeViewItemAction[] {
1011
const actions: DbTreeViewItemAction[] = [];
@@ -21,7 +22,9 @@ export function getDbItemActions(dbItem: DbItem): DbTreeViewItemAction[] {
2122
if (canBeOpenedOnGitHub(dbItem)) {
2223
actions.push("canBeOpenedOnGitHub");
2324
}
24-
25+
if (canImportCodeSearch(dbItem)) {
26+
actions.push("canImportCodeSearch");
27+
}
2528
return actions;
2629
}
2730

@@ -60,6 +63,10 @@ function canBeOpenedOnGitHub(dbItem: DbItem): boolean {
6063
return dbItemKindsThatCanBeOpenedOnGitHub.includes(dbItem.kind);
6164
}
6265

66+
function canImportCodeSearch(dbItem: DbItem): boolean {
67+
return DbItemKind.RemoteUserDefinedList === dbItem.kind;
68+
}
69+
6370
export function getGitHubUrl(dbItem: DbItem): string | undefined {
6471
switch (dbItem.kind) {
6572
case DbItemKind.RemoteOwner:

0 commit comments

Comments
 (0)