Skip to content

Commit 526c4f3

Browse files
committed
Remove root 'remote' node
1 parent 65623c0 commit 526c4f3

3 files changed

Lines changed: 16 additions & 72 deletions

File tree

extensions/ql-vscode/src/databases/db-manager.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ export class DbManager {
5858

5959
const expandedItems = this.getExpandedItems();
6060

61-
return ValueResult.ok([
62-
createRemoteTree(configResult.value, expandedItems),
63-
]);
61+
const remoteTree = createRemoteTree(configResult.value, expandedItems);
62+
return ValueResult.ok(remoteTree.children);
6463
}
6564

6665
public getConfigPath(): string {

extensions/ql-vscode/test/vscode-tests/minimal-workspace/databases/db-panel-rendering.test.ts

Lines changed: 10 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,11 @@ describe("db panel rendering nodes", () => {
5757

5858
expect(dbTreeItems).toBeTruthy();
5959
const items = dbTreeItems!;
60-
expect(items.length).toBe(1);
61-
62-
const remoteRootNode = items[0];
63-
expect(remoteRootNode.dbItem).toBeTruthy();
64-
expect(remoteRootNode.dbItem?.kind).toBe(DbItemKind.RootRemote);
65-
expect(remoteRootNode.label).toBe("remote");
66-
expect(remoteRootNode.tooltip).toBe("Remote databases");
67-
expect(remoteRootNode.collapsibleState).toBe(
68-
TreeItemCollapsibleState.Collapsed,
69-
);
70-
expect(remoteRootNode.children).toBeTruthy();
71-
expect(remoteRootNode.children.length).toBe(3);
60+
expect(items.length).toBe(3);
7261

73-
const systemDefinedListItems = remoteRootNode.children.filter(
74-
(item) => item.dbItem?.kind === DbItemKind.RemoteSystemDefinedList,
75-
);
76-
expect(systemDefinedListItems.length).toBe(3);
77-
checkRemoteSystemDefinedListItem(systemDefinedListItems[0], 10);
78-
checkRemoteSystemDefinedListItem(systemDefinedListItems[1], 100);
79-
checkRemoteSystemDefinedListItem(systemDefinedListItems[2], 1000);
62+
checkRemoteSystemDefinedListItem(items[0], 10);
63+
checkRemoteSystemDefinedListItem(items[1], 100);
64+
checkRemoteSystemDefinedListItem(items[2], 1000);
8065
});
8166

8267
it("should render remote repository list nodes", async () => {
@@ -98,22 +83,12 @@ describe("db panel rendering nodes", () => {
9883
const dbTreeItems = await dbTreeDataProvider.getChildren();
9984
expect(dbTreeItems).toBeTruthy();
10085

101-
const remoteRootNode = dbTreeItems?.find(
102-
(i) => i.dbItem?.kind === DbItemKind.RootRemote,
103-
);
104-
expect(remoteRootNode).toBeTruthy();
105-
expect(remoteRootNode!.collapsibleState).toBe(
106-
TreeItemCollapsibleState.Collapsed,
107-
);
108-
expect(remoteRootNode!.children).toBeTruthy();
109-
expect(remoteRootNode!.children.length).toBe(5);
110-
111-
const systemDefinedListItems = remoteRootNode!.children.filter(
86+
const systemDefinedListItems = dbTreeItems!.filter(
11287
(item) => item.dbItem?.kind === DbItemKind.RemoteSystemDefinedList,
11388
);
11489
expect(systemDefinedListItems.length).toBe(3);
11590

116-
const userDefinedListItems = remoteRootNode!.children.filter(
91+
const userDefinedListItems = dbTreeItems!.filter(
11792
(item) => item.dbItem?.kind === DbItemKind.RemoteUserDefinedList,
11893
);
11994
expect(userDefinedListItems.length).toBe(2);
@@ -137,20 +112,9 @@ describe("db panel rendering nodes", () => {
137112

138113
const dbTreeItems = await dbTreeDataProvider.getChildren();
139114
expect(dbTreeItems).toBeTruthy();
115+
expect(dbTreeItems?.length).toBe(5);
140116

141-
const remoteRootNode = dbTreeItems?.find(
142-
(i) => i.dbItem?.kind === DbItemKind.RootRemote,
143-
);
144-
expect(remoteRootNode).toBeTruthy();
145-
146-
expect(remoteRootNode!.dbItem).toBeTruthy();
147-
expect(remoteRootNode!.collapsibleState).toBe(
148-
TreeItemCollapsibleState.Collapsed,
149-
);
150-
expect(remoteRootNode!.children).toBeTruthy();
151-
expect(remoteRootNode!.children.length).toBe(5);
152-
153-
const ownerListItems = remoteRootNode!.children.filter(
117+
const ownerListItems = dbTreeItems!.filter(
154118
(item) => item.dbItem?.kind === DbItemKind.RemoteOwner,
155119
);
156120
expect(ownerListItems.length).toBe(2);
@@ -167,20 +131,9 @@ describe("db panel rendering nodes", () => {
167131

168132
const dbTreeItems = await dbTreeDataProvider.getChildren();
169133
expect(dbTreeItems).toBeTruthy();
134+
expect(dbTreeItems!.length).toBe(5);
170135

171-
const remoteRootNode = dbTreeItems?.find(
172-
(i) => i.dbItem?.kind === DbItemKind.RootRemote,
173-
);
174-
expect(remoteRootNode).toBeTruthy();
175-
176-
expect(remoteRootNode!.dbItem).toBeTruthy();
177-
expect(remoteRootNode!.collapsibleState).toBe(
178-
TreeItemCollapsibleState.Collapsed,
179-
);
180-
expect(remoteRootNode!.children).toBeTruthy();
181-
expect(remoteRootNode!.children.length).toBe(5);
182-
183-
const repoItems = remoteRootNode!.children.filter(
136+
const repoItems = dbTreeItems!.filter(
184137
(item) => item.dbItem?.kind === DbItemKind.RemoteRepo,
185138
);
186139
expect(repoItems.length).toBe(2);

extensions/ql-vscode/test/vscode-tests/no-workspace/databases/db-panel-selection.test.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,12 @@ describe("db panel selection", () => {
7575
expect(dbTreeItems).toBeTruthy();
7676
const items = dbTreeItems!;
7777

78-
const remoteRootNode = items[0];
79-
expect(remoteRootNode.dbItem).toBeTruthy();
80-
expect(remoteRootNode.dbItem?.kind).toEqual(DbItemKind.RootRemote);
81-
82-
const list1 = remoteRootNode.children.find(
78+
const list1 = items.find(
8379
(c) =>
8480
c.dbItem?.kind === DbItemKind.RemoteUserDefinedList &&
8581
c.dbItem?.listName === "my-list-1",
8682
);
87-
const list2 = remoteRootNode.children.find(
83+
const list2 = items.find(
8884
(c) =>
8985
c.dbItem?.kind === DbItemKind.RemoteUserDefinedList &&
9086
c.dbItem?.listName === "my-list-2",
@@ -123,11 +119,7 @@ describe("db panel selection", () => {
123119
expect(dbTreeItems).toBeTruthy();
124120
const items = dbTreeItems!;
125121

126-
const remoteRootNode = items[0];
127-
expect(remoteRootNode.dbItem).toBeTruthy();
128-
expect(remoteRootNode.dbItem?.kind).toEqual(DbItemKind.RootRemote);
129-
130-
const list2 = remoteRootNode.children.find(
122+
const list2 = items.find(
131123
(c) =>
132124
c.dbItem?.kind === DbItemKind.RemoteUserDefinedList &&
133125
c.dbItem?.listName === "my-list-2",
@@ -150,7 +142,7 @@ describe("db panel selection", () => {
150142
expect(repo2Node).toBeTruthy();
151143
expect(isTreeViewItemSelectable(repo2Node!)).toBeTruthy();
152144

153-
for (const item of remoteRootNode.children) {
145+
for (const item of items) {
154146
expect(isTreeViewItemSelectable(item)).toBeTruthy();
155147
}
156148
});

0 commit comments

Comments
 (0)