Skip to content

Commit 15455f9

Browse files
authored
Hide Servers tree icon buttons for creating workspace folders for servers that don't support this (#299)
1 parent e3ecdfe commit 15455f9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/ui/serverManagerView.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,11 @@ function allServers(treeItem: SMTreeItem, params?: any): ServerTreeItem[] {
263263
const children: ServerTreeItem[] = [];
264264
// Add children for servers defined at the user or workspace level
265265
const wsServerNames = getServerNames(undefined);
266+
const wsIsFolder = !vscode.workspace.workspaceFile;
267+
const conf = vscode.workspace.getConfiguration("intersystems.servers");
266268
children.push(...wsServerNames.map((wss) => {
267-
return new ServerTreeItem({ label: wss.name, id: wss.name, parent: treeItem }, wss);
269+
// If the server is defined at the workspace level and the workspace is a folder then it's effectively defined at the workspace folder level
270+
return new ServerTreeItem({ label: `${wss.name}${wsIsFolder && typeof conf.inspect(wss.name)?.workspaceValue == "object" ? ` (${(vscode.workspace.workspaceFolders ?? [])[0]?.name})` : ""}`, id: wss.name, parent: treeItem }, wss);
268271
}));
269272
// Add children for servers defined at the workspace folder level
270273
vscode.workspace.workspaceFolders?.map((wf) => {
@@ -312,7 +315,9 @@ async function currentServers(element: SMTreeItem, params?: any): Promise<Server
312315
} else if (connServer) {
313316
const serverSummary = getServerSummary(connServer, folder);
314317
if (serverSummary) {
315-
const key = `${connServer}${typeof vscode.workspace.getConfiguration("intersystems.servers", folder).inspect(connServer)?.workspaceFolderValue == "object"
318+
const inspection = vscode.workspace.getConfiguration("intersystems.servers", folder).inspect(connServer);
319+
// If the server is defined at the workspace level and the workspace is a folder then it's effectively defined at the workspace folder level
320+
const key = `${connServer}${typeof inspection?.workspaceFolderValue == "object" || (typeof inspection?.workspaceValue == "object" && !vscode.workspace.workspaceFile)
316321
? ` (${folder.name})` : ""
317322
}`;
318323
children.set(
@@ -533,7 +538,7 @@ async function serverNamespaces(element: ServerTreeItem, params?: any): Promise<
533538

534539
/** Returns `true` if `server` is a tree item representing a server defined at the workspace folder level */
535540
function serverItemIsWsFolder(server?: SMTreeItem): boolean {
536-
return typeof server?.label == "string" && server.label.includes("(") && server.label.endsWith(")");
541+
return typeof server?.label == "string" && ((server.label.includes("(") && server.label.endsWith(")")) || server.label.startsWith("docker:"));
537542
}
538543

539544
// tslint:disable-next-line: max-classes-per-file

0 commit comments

Comments
 (0)