Skip to content

Commit 6556839

Browse files
authored
Show servers defined in workspace folder settings in All Servers UI (#276)
1 parent 04f04da commit 6556839

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

src/api/getServerNames.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export function getServerNames(scope?: vscode.ConfigurationScope, sorted?: boole
1616
description: `${servers[myDefault].description || ""} (default)`.trim(),
1717
detail: serverDetail(servers[myDefault]),
1818
name: myDefault,
19+
scope,
1920
});
2021
}
2122

@@ -26,15 +27,14 @@ export function getServerNames(scope?: vscode.ConfigurationScope, sorted?: boole
2627
description: servers[key].description || "",
2728
detail: serverDetail(servers[key]),
2829
name: key,
30+
scope,
2931
});
3032
}
3133
}
3234
}
3335

3436
// If requested, sort what we found
35-
if (sorted) {
36-
names = names.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
37-
}
37+
if (sorted) names.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
3838

3939
// Append them
4040
allNames.push(...names);

src/commonActivate.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ export function commonActivate(context: vscode.ExtensionContext, view: ServerMan
295295
vscode.commands.registerCommand(`${extensionId}.viewWebApp`, async (webAppTreeItem?: WebAppTreeItem) => {
296296
await addWorkspaceFolderAsync(true, true, <NamespaceTreeItem>webAppTreeItem?.parent?.parent, undefined, webAppTreeItem?.name);
297297
}),
298+
vscode.workspace.onDidChangeWorkspaceFolders(() => view.refreshTree()),
298299
// Listen for relevant configuration changes
299300
vscode.workspace.onDidChangeConfiguration((e) => {
300301
if (e.affectsConfiguration("intersystems.servers") || e.affectsConfiguration("objectscript.conn")) {

src/ui/serverManagerView.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,19 @@ export class SMTreeItem extends vscode.TreeItem {
261261

262262
function allServers(treeItem: SMTreeItem, params?: any): ServerTreeItem[] {
263263
const children: ServerTreeItem[] = [];
264-
const getAllServers = (sorted?: boolean): ServerTreeItem[] => {
265-
const serverNames = getServerNames(undefined, sorted);
266-
return serverNames.map((serverName) => {
267-
return new ServerTreeItem({ label: serverName.name, id: serverName.name, parent: treeItem }, serverName);
268-
});
269-
};
270-
271-
getAllServers(params.sorted).map((server) => children.push(server));
264+
// Add children for servers defined at the user or workspace level
265+
const wsServerNames = getServerNames(undefined);
266+
children.push(...wsServerNames.map((wss) => {
267+
return new ServerTreeItem({ label: wss.name, id: wss.name, parent: treeItem }, wss);
268+
}));
269+
// Add children for servers defined at the workspace folder level
270+
vscode.workspace.workspaceFolders?.map((wf) => {
271+
if (["isfs", "isfs-readonly"].includes(wf.uri.scheme)) return;
272+
children.push(...getServerNames(wf).filter((wfs) => !wsServerNames.some((wss) => wss.name == wfs.name)).map((wfs) => {
273+
return new ServerTreeItem({ label: `${wfs.name} (${wf.name})`, id: wfs.name, parent: treeItem }, wfs);
274+
}));
275+
});
276+
if (params?.sorted) children.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
272277
return children;
273278
}
274279

@@ -304,13 +309,15 @@ async function currentServers(element: SMTreeItem, params?: any): Promise<Server
304309
}
305310
}
306311
}
307-
}
308-
else if (connServer) {
312+
} else if (connServer) {
309313
const serverSummary = getServerSummary(connServer, folder);
310314
if (serverSummary) {
315+
const key = `${connServer}${typeof vscode.workspace.getConfiguration("intersystems.servers", folder).inspect(connServer)?.workspaceFolderValue == "object"
316+
? ` (${folder.name})` : ""
317+
}`;
311318
children.set(
312-
connServer,
313-
new ServerTreeItem({ parent: element, label: serverName, id: serverName }, serverSummary),
319+
key,
320+
new ServerTreeItem({ parent: element, label: key, id: serverName }, serverSummary),
314321
);
315322
}
316323
}

0 commit comments

Comments
 (0)