Skip to content

Commit 774a50a

Browse files
Merge pull request #421 from gjsjohnmurray/fix-415
fix #415 use less statusbar space
2 parents 56cf68e + 454f3c0 commit 774a50a

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

src/api/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ export class AtelierAPI {
289289
throw response;
290290
}
291291
await this.updateCookies(response.headers.raw()["set-cookie"] || []);
292-
panel.text = `${connInfo} - Connected`;
292+
panel.text = `${connInfo}`;
293+
panel.tooltip = `Connected as ${username}`;
293294
if (method === "HEAD") {
294295
return this.cookies;
295296
}
@@ -331,7 +332,8 @@ export class AtelierAPI {
331332
}
332333
} catch (error) {
333334
if (error.error && error.error.code === "ECONNREFUSED") {
334-
panel.text = `${connInfo} - Disconnected`;
335+
panel.text = `${connInfo} $(debug-disconnect)`;
336+
panel.tooltip = "Disconnected";
335337
workspaceState.update(this.configName + ":host", undefined);
336338
workspaceState.update(this.configName + ":port", undefined);
337339
setTimeout(checkConnection, 30000);

src/extension.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ import { CodeActionProvider } from "./providers/CodeActionProvider";
9898
const packageJson = vscode.extensions.getExtension(extensionId).packageJSON;
9999
const extensionVersion = packageJson.version;
100100
const aiKey = packageJson.aiKey;
101+
const PANEL_LABEL = "ObjectScript";
101102

102103
const _onDidChangeConnection = new vscode.EventEmitter<void>();
103104

@@ -197,18 +198,19 @@ export async function checkConnection(clearCookies = false, uri?: vscode.Uri): P
197198
_onDidChangeConnection.fire();
198199
}
199200
let api = new AtelierAPI(apiTarget, false);
200-
const { active, host = "", port = 0, ns = "" } = api.config;
201+
const { active, host = "", port = 0, username, ns = "" } = api.config;
201202
let connInfo = `${host}:${port}[${ns}]`;
202203
if (!host.length || !port || !ns.length) {
203204
connInfo = packageJson.displayName;
204205
}
205-
panel.text = connInfo;
206-
panel.tooltip = "";
207206
vscode.commands.executeCommand("setContext", "vscode-objectscript.connectActive", active);
208207
if (!active) {
209-
panel.text = `${packageJson.displayName} - Disabled`;
208+
panel.text = `${PANEL_LABEL} $(warning)`;
209+
panel.tooltip = `Connection to ${connInfo} is disabled`;
210210
return;
211211
}
212+
panel.text = connInfo;
213+
panel.tooltip = `Connected as ${username}`;
212214
if (!workspaceState.get(configName + ":port") && !api.externalServer) {
213215
try {
214216
const { port: dockerPort, docker: withDocker } = await portFromDockerCompose();
@@ -217,7 +219,8 @@ export async function checkConnection(clearCookies = false, uri?: vscode.Uri): P
217219
if (!dockerPort) {
218220
const errorMessage = `Something is wrong with your docker-compose connection settings, or your service is not running.`;
219221
outputChannel.appendError(errorMessage);
220-
panel.text = `${packageJson.displayName} - ERROR`;
222+
panel.text = `${PANEL_LABEL} $(error)`;
223+
panel.tooltip = `ERROR - ${errorMessage}`;
221224
return;
222225
}
223226
const { autoShowTerminal } = config();
@@ -244,10 +247,10 @@ export async function checkConnection(clearCookies = false, uri?: vscode.Uri): P
244247
api = new AtelierAPI(apiTarget, false);
245248

246249
if (!api.config.host || !api.config.port || !api.config.ns) {
247-
const message = "host, port and ns must be specified.";
250+
const message = "'host', 'port' and 'ns' must be specified.";
248251
outputChannel.appendError(message);
249-
panel.text = `${packageJson.displayName} - ERROR`;
250-
panel.tooltip = message;
252+
panel.text = `${PANEL_LABEL} $(error)`;
253+
panel.tooltip = `ERROR - ${message}`;
251254
return;
252255
}
253256
api
@@ -293,14 +296,14 @@ export async function checkConnection(clearCookies = false, uri?: vscode.Uri): P
293296
);
294297
}
295298
}, 1000);
296-
message = "Not Authorized";
299+
message = "Not Authorized.";
297300
errorMessage = `Authorization error: Check your credentials in Settings, and that you have sufficient privileges on the /api/atelier web application on ${connInfo}`;
298301
} else {
299302
errorMessage = `${message}\nCheck your server details in Settings (${connInfo}).`;
300303
}
301304
outputChannel.appendError(errorMessage);
302-
panel.text = `${connInfo} - ERROR`;
303-
panel.tooltip = message;
305+
panel.text = `${connInfo} $(error)`;
306+
panel.tooltip = `ERROR - ${message}`;
304307
throw error;
305308
})
306309
.finally(() => {

0 commit comments

Comments
 (0)