diff --git a/README.md b/README.md index d9f3e90..4e6be20 100644 --- a/README.md +++ b/README.md @@ -174,8 +174,7 @@ In this example two connections have been defined: }, "description": "My local IRIS instance" }, - "/default": "my-local", - "/hideEmbeddedEntries": true + "/default": "my-local" } ``` @@ -185,8 +184,6 @@ Notice how you can add a `description` property to each connection. This will be 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. -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). - --- ## Technical Notes @@ -197,12 +194,10 @@ These features use VS Code's extension-private global state storage. Data is not ### The 'All Servers' Folder -The `All Servers` tree respects the optional `/default` and `/hideEmbeddedEntries` settings in the `intersystems.servers` JSON. +The `All Servers` tree respects the optional `/default` setting in the `intersystems.servers` JSON. If a server has been named in `/default` it is promoted to the top of the list, which is otherwise presented in alphabetical order. -Embedded entries (built-in default ones) are demoted to the end of the list, or omitted completely if `/hideEmbeddedEntries` is true. - --- ## Information for VS Code Extension Developers - How To Leverage Server Manager diff --git a/package.json b/package.json index 8209482..89cf499 100644 --- a/package.json +++ b/package.json @@ -101,33 +101,6 @@ "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.", "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.", "scope": "resource", - "default": { - "default~iris": { - "webServer": { - "scheme": "http", - "host": "127.0.0.1", - "port": 52773 - }, - "description": "Connection to local InterSystems IRIS™ installed with default settings." - }, - "default~cache": { - "webServer": { - "scheme": "http", - "host": "127.0.0.1", - "port": 57772 - }, - "description": "Connection to local InterSystems Caché installed with default settings." - }, - "default~ensemble": { - "webServer": { - "scheme": "http", - "host": "127.0.0.1", - "port": 57772 - }, - "description": "Connection to local InterSystems Ensemble installed with default settings." - }, - "/default": "default~iris" - }, "patternProperties": { "^[a-z0-9-_~]+$": { "type": "object", @@ -237,10 +210,6 @@ "/default": { "type": "string", "description": "Name of the server to promote to the top of pick lists." - }, - "/hideEmbeddedEntries": { - "type": "boolean", - "description": "Do not append the built-in 'default~*' server definitions to pick lists." } }, "additionalProperties": false diff --git a/src/api/getServerNames.ts b/src/api/getServerNames.ts index e78a60c..909efa3 100644 --- a/src/api/getServerNames.ts +++ b/src/api/getServerNames.ts @@ -5,23 +5,12 @@ import { serverDetail } from "./getServerSummary"; export function getServerNames(scope?: vscode.ConfigurationScope, sorted?: boolean): IServerName[] { const allNames: IServerName[] = []; let names: IServerName[] = []; - const embeddedNames: IServerName[] = []; const servers = vscode.workspace.getConfiguration("intersystems", scope).get("servers"); if (typeof servers === "object" && servers) { - // Helper function to return true iff inspected setting is not explicitly set at any level - const notSet = (inspected): boolean => { - return !inspected?.globalLanguageValue - && !inspected?.globalValue - && !inspected?.workspaceFolderLanguageValue - && !inspected?.workspaceFolderValue - && !inspected?.workspaceLanguageValue - && !inspected?.workspaceValue; - }; - // If a valid default has been explicitly nominated, add it first - const inspectedDefault = vscode.workspace.getConfiguration("intersystems.servers", scope).inspect("/default"); - const myDefault: string = notSet(inspectedDefault) ? "" : servers["/default"] || ""; + // If a valid default has been set, add it first + const myDefault: string = servers["/default"] || ""; if (myDefault.length > 0 && servers[myDefault]) { allNames.push({ description: `${servers[myDefault].description || ""} (default)`.trim(), @@ -33,22 +22,11 @@ export function getServerNames(scope?: vscode.ConfigurationScope, sorted?: boole // Process the rest for (const key in servers) { if (!key.startsWith("/") && key !== myDefault) { - const inspected = vscode.workspace.getConfiguration("intersystems.servers", scope).inspect(key); - - // Collect embedded (default~*) servers separately - if (notSet(inspected)) { - embeddedNames.push({ - description: servers[key].description || "", - detail: serverDetail(servers[key]), - name: key, - }); - } else { - names.push({ - description: servers[key].description || "", - detail: serverDetail(servers[key]), - name: key, - }); - } + names.push({ + description: servers[key].description || "", + detail: serverDetail(servers[key]), + name: key, + }); } } } @@ -60,10 +38,5 @@ export function getServerNames(scope?: vscode.ConfigurationScope, sorted?: boole // Append them allNames.push(...names); - - // Append the embedded servers unless suppressed - if (!vscode.workspace.getConfiguration("intersystems.servers", scope).get("/hideEmbeddedEntries")) { - allNames.push(...embeddedNames); - } return allNames; } diff --git a/src/api/getServerSpec.ts b/src/api/getServerSpec.ts index cdbb196..6c5474d 100644 --- a/src/api/getServerSpec.ts +++ b/src/api/getServerSpec.ts @@ -26,7 +26,8 @@ export async function getServerSpec( if (flushCredentialCache) { credentialCache[name] = undefined; } - let server: IServerSpec | undefined = vscode.workspace.getConfiguration("intersystems.servers", scope).get(name); + // To avoid breaking existing users, continue to return a default server definition even after we dropped that feature + let server: IServerSpec | undefined = vscode.workspace.getConfiguration("intersystems.servers", scope).get(name) || legacyEmbeddedServer(name); // Unknown server if (!server) { @@ -51,3 +52,43 @@ export async function getServerSpec( } return server; } + +/** + * If name is one of the embedded server definitions we previously (pre-3.4.2) specified in the "default" section of the "intersystems.servers" + * object spec in package.json then return what getConfiguration() would have returned. + * + * @param name The name. + * @returns Server specification or undefined. + */ +export function legacyEmbeddedServer(name: string): IServerSpec | undefined { + return { + "default~iris": { + "name": "default~iris", + "webServer": { + "scheme": "http", + "host": "127.0.0.1", + "port": 52773 + }, + "description": "Connection to local InterSystems IRIS™ installed with default settings." + }, + "default~cache": { + "name": "default~cache", + "webServer": { + "scheme": "http", + "host": "127.0.0.1", + "port": 57772 + }, + "description": "Connection to local InterSystems Caché installed with default settings." + }, + "default~ensemble": { + "name": "default~ensemble", + "webServer": { + "scheme": "http", + "host": "127.0.0.1", + "port": 57772 + }, + "description": "Connection to local InterSystems Ensemble installed with default settings." + } + }[name]; +} + diff --git a/src/api/getServerSummary.ts b/src/api/getServerSummary.ts index 779e5cf..7793e07 100644 --- a/src/api/getServerSummary.ts +++ b/src/api/getServerSummary.ts @@ -1,8 +1,10 @@ import * as vscode from "vscode"; import { IServerName, IServerSpec } from "@intersystems-community/intersystems-servermanager"; +import { legacyEmbeddedServer } from "./getServerSpec"; export function getServerSummary(name: string, scope?: vscode.ConfigurationScope): IServerName | undefined { - const server: IServerSpec | undefined = vscode.workspace.getConfiguration("intersystems.servers", scope).get(name); + // To avoid breaking existing users, continue to return a default server definition even after we dropped that feature + const server: IServerSpec | undefined = vscode.workspace.getConfiguration("intersystems.servers", scope).get(name) || legacyEmbeddedServer(name); if (!server) { return undefined; }