Skip to content

Commit f3a2b12

Browse files
authored
Show server name in Status Bar (#1017)
1 parent dbbe186 commit f3a2b12

File tree

6 files changed

+44
-11
lines changed

6 files changed

+44
-11
lines changed

docs/Configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ If you want to store a password for this server definition, select **Store Passw
150150

151151
You can create a configuration for a server that is not currently running.
152152

153-
If you are connecting via a standalone web server which bublishes services for more than one InterSystems server you will need to edit the server configuration in your `settings.json` file to add a `pathPrefix` property. See the next section.
153+
If you are connecting via a standalone web server which publishes services for more than one InterSystems server you will need to edit the server configuration in your `settings.json` file to add a `pathPrefix` property. See the next section.
154154

155155
## Editing a Server Configuration
156156

docs/ExtensionUI.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,21 @@ Technically the **InterSystems Tools** and **ObjectScript** entities described a
133133
When a VS Code container has only a single view in it the view header merges with the container header, with the two names separated by a colon.
134134

135135
Views can be dragged between containers, so for example you could move Explorer off its ObjectScript container and onto the InterSystems Tools container. Or move Servers onto the ObjectScript container. Or move either of them onto VS Code's main Explorer container.
136+
137+
## Server Connection Status Bar Item
138+
139+
The connection status of the current server can be seen in the [VS Code status bar](https://code.visualstudio.com/api/ux-guidelines/status-bar). If the server connection is active, the connected server and namespace will be shown in the status bar. If the server connection info is defined in the [`intersystems.servers` setting object](../settings/#intersystems-servermanager), the name of the server and namepsace will be shown:
140+
141+
![Status bar name](../assets/images/server-status-bar.png "status bar name")
142+
143+
Otherwise, the host, port and namespace will be shown:
144+
145+
![Status bar host port](../assets/images/action-for-server-start.png "status bar host port")
146+
147+
Hover over the status bar item to see more detailed connection information, like a full connection URL and the username of the connection. Click on the status bar item to open the Server Actions menu. Custom entries [can be added](../configuration/#server-actions-menu) to this menu.
148+
149+
If the server connection is inactive, the connection info or the word `ObjectScript` will be shown, accompanied by an error or warning icon:
150+
151+
![Status bar error](../assets/images/server-status-bar-error.png "status bar error")
152+
153+
Hover over the status bar item to see more detailed error information. Click on the status bar item to open a menu that will help you activate your connection.
48.8 KB
Loading
50.6 KB
Loading

src/api/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,15 @@ export class AtelierAPI {
228228
}
229229

230230
public get connInfo(): string {
231-
const { host, port, docker, dockerService } = this.config;
231+
const { serverName, host, port, docker, dockerService } = this.config;
232232
const ns = this.ns.toUpperCase();
233-
return (docker ? "docker" + (dockerService ? `:${dockerService}:${port}` : "") : `${host}:${port}`) + `[${ns}]`;
233+
return (
234+
(docker
235+
? "docker" + (dockerService ? `:${dockerService}:${port}` : "")
236+
: serverName
237+
? serverName
238+
: `${host}:${port}`) + `[${ns}]`
239+
);
234240
}
235241

236242
public async request(

src/extension.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export const extensionId = "intersystems-community.vscode-objectscript";
33
import vscode = require("vscode");
44
import * as semver from "semver";
55

6-
import { AtelierJob } from "./api/atelier";
6+
import { AtelierJob, Content, Response, ServerInfo } from "./api/atelier";
77
export const OBJECTSCRIPT_FILE_SCHEMA = "objectscript";
88
export const OBJECTSCRIPTXML_FILE_SCHEMA = "objectscriptxml";
99
export const FILESYSTEM_SCHEMA = "isfs";
@@ -253,7 +253,7 @@ export async function checkConnection(
253253
_onDidChangeConnection.fire();
254254
}
255255
let api = new AtelierAPI(apiTarget, false);
256-
const { active, host = "", port = 0, pathPrefix, username, ns = "" } = api.config;
256+
const { active, host = "", port = 0, username, ns = "" } = api.config;
257257
vscode.commands.executeCommand("setContext", "vscode-objectscript.connectActive", active);
258258
if (!panel.text) {
259259
panel.text = `${PANEL_LABEL}`;
@@ -265,11 +265,12 @@ export async function checkConnection(
265265
}
266266
let connInfo = api.connInfo;
267267
if (!active) {
268-
if (!host.length || !port || !ns.length) {
269-
connInfo = `incompletely specified server ${connInfo}`;
270-
}
271268
panel.text = `${PANEL_LABEL} $(warning)`;
272-
panel.tooltip = `Connection to ${connInfo} is disabled`;
269+
panel.tooltip = new vscode.MarkdownString(
270+
`Connection to${
271+
!host.length || !port || !ns.length ? " incompletely specified server" : ""
272+
} \`${connInfo}\` is disabled`
273+
);
273274
return;
274275
}
275276

@@ -324,9 +325,17 @@ export async function checkConnection(
324325
checkingConnection = true;
325326

326327
// What we do when api.serverInfo call succeeds
327-
const gotServerInfo = async (info) => {
328+
const gotServerInfo = async (info: Response<Content<ServerInfo>>) => {
328329
panel.text = api.connInfo;
329-
panel.tooltip = `Connected${pathPrefix ? " to " + pathPrefix : ""} as ${username}`;
330+
if (api.config.serverName) {
331+
panel.tooltip = new vscode.MarkdownString(
332+
`Connected to \`${api.config.host}:${api.config.port}${api.config.pathPrefix}\` as \`${username}\``
333+
);
334+
} else {
335+
panel.tooltip = new vscode.MarkdownString(
336+
`Connected${api.config.pathPrefix ? ` to \`${api.config.pathPrefix}\`` : ""} as \`${username}\``
337+
);
338+
}
330339
const hasHS = info.result.content.features.find((el) => el.name === "HEALTHSHARE" && el.enabled) !== undefined;
331340
reporter &&
332341
reporter.sendTelemetryEvent("connected", {

0 commit comments

Comments
 (0)