Skip to content

Commit 1fc0d18

Browse files
committed
Remove default servers and the /hideEmbedded switch (#203)
1 parent 20d3f62 commit 1fc0d18

File tree

5 files changed

+54
-74
lines changed

5 files changed

+54
-74
lines changed

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ In this example two connections have been defined:
174174
},
175175
"description": "My local IRIS instance"
176176
},
177-
"/default": "my-local",
178-
"/hideEmbeddedEntries": true
177+
"/default": "my-local"
179178
}
180179
```
181180

@@ -185,8 +184,6 @@ Notice how you can add a `description` property to each connection. This will be
185184

186185
Servers are displayed in the quickpick in the order they are defined in the JSON file. The exception is that if a server name is set as the value of the `/default` property (see example above) it will be shown first in the list.
187186

188-
A set of embedded servers with names beginning `default~` will appear at the end of the lists unless you add the property `"/hideEmbeddedEntries": true` to your `intersystems.server` object to hide them (see above).
189-
190187
---
191188

192189
## Technical Notes
@@ -197,12 +194,10 @@ These features use VS Code's extension-private global state storage. Data is not
197194

198195
### The 'All Servers' Folder
199196

200-
The `All Servers` tree respects the optional `/default` and `/hideEmbeddedEntries` settings in the `intersystems.servers` JSON.
197+
The `All Servers` tree respects the optional `/default` setting in the `intersystems.servers` JSON.
201198

202199
If a server has been named in `/default` it is promoted to the top of the list, which is otherwise presented in alphabetical order.
203200

204-
Embedded entries (built-in default ones) are demoted to the end of the list, or omitted completely if `/hideEmbeddedEntries` is true.
205-
206201
---
207202

208203
## Information for VS Code Extension Developers - How To Leverage Server Manager

package.json

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -101,33 +101,6 @@
101101
"description": "InterSystems servers that other extensions connect to. Each property of this object names a server and holds nested properties specifying how to connect to it.",
102102
"markdownDescription": "[InterSystems](https://www.intersystems.com) servers that other extensions connect to. Each property of this object names a server and holds nested properties specifying how to connect to it. Server names may only contain characters 'A' to 'Z', 'a' to 'z', digits, '-', '.', '_' and '~' characters.",
103103
"scope": "resource",
104-
"default": {
105-
"default~iris": {
106-
"webServer": {
107-
"scheme": "http",
108-
"host": "127.0.0.1",
109-
"port": 52773
110-
},
111-
"description": "Connection to local InterSystems IRIS™ installed with default settings."
112-
},
113-
"default~cache": {
114-
"webServer": {
115-
"scheme": "http",
116-
"host": "127.0.0.1",
117-
"port": 57772
118-
},
119-
"description": "Connection to local InterSystems Caché installed with default settings."
120-
},
121-
"default~ensemble": {
122-
"webServer": {
123-
"scheme": "http",
124-
"host": "127.0.0.1",
125-
"port": 57772
126-
},
127-
"description": "Connection to local InterSystems Ensemble installed with default settings."
128-
},
129-
"/default": "default~iris"
130-
},
131104
"patternProperties": {
132105
"^[a-z0-9-_~]+$": {
133106
"type": "object",
@@ -237,10 +210,6 @@
237210
"/default": {
238211
"type": "string",
239212
"description": "Name of the server to promote to the top of pick lists."
240-
},
241-
"/hideEmbeddedEntries": {
242-
"type": "boolean",
243-
"description": "Do not append the built-in 'default~*' server definitions to pick lists."
244213
}
245214
},
246215
"additionalProperties": false

src/api/getServerNames.ts

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,12 @@ import { serverDetail } from "./getServerSummary";
55
export function getServerNames(scope?: vscode.ConfigurationScope, sorted?: boolean): IServerName[] {
66
const allNames: IServerName[] = [];
77
let names: IServerName[] = [];
8-
const embeddedNames: IServerName[] = [];
98
const servers = vscode.workspace.getConfiguration("intersystems", scope).get("servers");
109

1110
if (typeof servers === "object" && servers) {
12-
// Helper function to return true iff inspected setting is not explicitly set at any level
13-
const notSet = (inspected): boolean => {
14-
return !inspected?.globalLanguageValue
15-
&& !inspected?.globalValue
16-
&& !inspected?.workspaceFolderLanguageValue
17-
&& !inspected?.workspaceFolderValue
18-
&& !inspected?.workspaceLanguageValue
19-
&& !inspected?.workspaceValue;
20-
};
2111

22-
// If a valid default has been explicitly nominated, add it first
23-
const inspectedDefault = vscode.workspace.getConfiguration("intersystems.servers", scope).inspect("/default");
24-
const myDefault: string = notSet(inspectedDefault) ? "" : servers["/default"] || "";
12+
// If a valid default has been set, add it first
13+
const myDefault: string = servers["/default"] || "";
2514
if (myDefault.length > 0 && servers[myDefault]) {
2615
allNames.push({
2716
description: `${servers[myDefault].description || ""} (default)`.trim(),
@@ -33,22 +22,11 @@ export function getServerNames(scope?: vscode.ConfigurationScope, sorted?: boole
3322
// Process the rest
3423
for (const key in servers) {
3524
if (!key.startsWith("/") && key !== myDefault) {
36-
const inspected = vscode.workspace.getConfiguration("intersystems.servers", scope).inspect(key);
37-
38-
// Collect embedded (default~*) servers separately
39-
if (notSet(inspected)) {
40-
embeddedNames.push({
41-
description: servers[key].description || "",
42-
detail: serverDetail(servers[key]),
43-
name: key,
44-
});
45-
} else {
46-
names.push({
47-
description: servers[key].description || "",
48-
detail: serverDetail(servers[key]),
49-
name: key,
50-
});
51-
}
25+
names.push({
26+
description: servers[key].description || "",
27+
detail: serverDetail(servers[key]),
28+
name: key,
29+
});
5230
}
5331
}
5432
}
@@ -60,10 +38,5 @@ export function getServerNames(scope?: vscode.ConfigurationScope, sorted?: boole
6038

6139
// Append them
6240
allNames.push(...names);
63-
64-
// Append the embedded servers unless suppressed
65-
if (!vscode.workspace.getConfiguration("intersystems.servers", scope).get("/hideEmbeddedEntries")) {
66-
allNames.push(...embeddedNames);
67-
}
6841
return allNames;
6942
}

src/api/getServerSpec.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export async function getServerSpec(
2626
if (flushCredentialCache) {
2727
credentialCache[name] = undefined;
2828
}
29-
let server: IServerSpec | undefined = vscode.workspace.getConfiguration("intersystems.servers", scope).get(name);
29+
// To avoid breaking existing users, continue to return a default server definition even after we dropped that feature
30+
let server: IServerSpec | undefined = vscode.workspace.getConfiguration("intersystems.servers", scope).get(name) || legacyEmbeddedServer(name);
3031

3132
// Unknown server
3233
if (!server) {
@@ -51,3 +52,43 @@ export async function getServerSpec(
5152
}
5253
return server;
5354
}
55+
56+
/**
57+
* If name is one of the embedded server definitions we previously (pre-3.4.2) specified in the "default" section of the "intersystems.servers"
58+
* object spec in package.json then return what getConfiguration() would have returned.
59+
*
60+
* @param name The name.
61+
* @returns Server specification or undefined.
62+
*/
63+
export function legacyEmbeddedServer(name: string): IServerSpec | undefined {
64+
return {
65+
"default~iris": {
66+
"name": "default~iris",
67+
"webServer": {
68+
"scheme": "http",
69+
"host": "127.0.0.1",
70+
"port": 52773
71+
},
72+
"description": "Connection to local InterSystems IRIS™ installed with default settings."
73+
},
74+
"default~cache": {
75+
"name": "default~cache",
76+
"webServer": {
77+
"scheme": "http",
78+
"host": "127.0.0.1",
79+
"port": 57772
80+
},
81+
"description": "Connection to local InterSystems Caché installed with default settings."
82+
},
83+
"default~ensemble": {
84+
"name": "default~ensemble",
85+
"webServer": {
86+
"scheme": "http",
87+
"host": "127.0.0.1",
88+
"port": 57772
89+
},
90+
"description": "Connection to local InterSystems Ensemble installed with default settings."
91+
}
92+
}[name];
93+
}
94+

src/api/getServerSummary.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import * as vscode from "vscode";
22
import { IServerName, IServerSpec } from "@intersystems-community/intersystems-servermanager";
3+
import { legacyEmbeddedServer } from "./getServerSpec";
34

45
export function getServerSummary(name: string, scope?: vscode.ConfigurationScope): IServerName | undefined {
5-
const server: IServerSpec | undefined = vscode.workspace.getConfiguration("intersystems.servers", scope).get(name);
6+
// To avoid breaking existing users, continue to return a default server definition even after we dropped that feature
7+
const server: IServerSpec | undefined = vscode.workspace.getConfiguration("intersystems.servers", scope).get(name) || legacyEmbeddedServer(name);
68
if (!server) {
79
return undefined;
810
}

0 commit comments

Comments
 (0)