Skip to content

Commit

Permalink
Allow hiding status bar item via settings (#142)
Browse files Browse the repository at this point in the history
* Allow hiding status bar picker via settings

* Rename "showStatusBarItem" to "showEnvironmentStatusBarItem"
  • Loading branch information
VFK authored and Huachao committed Dec 8, 2017
1 parent 18b5de3 commit cb5f963
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,12 @@
"default": "full",
"scope": "resource",
"description": "Response preview output option. 'full' for whole response message(status line, headers and body). 'headers' for response headers(as well as status line). 'body' for response body only. 'exchange' for whole HTTP exchange (request and response)"
},
"rest-client.showEnvironmentStatusBarItem": {
"type": "boolean",
"default": true,
"scope": "resource",
"description": "Show environment picker in status bar"
}
}
}
Expand Down
17 changes: 11 additions & 6 deletions src/controllers/environmentController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ export class EnvironmentController {
private _restClientSettings: RestClientSettings;

public constructor(initEnvironment: EnvironmentPickItem) {
this._environmentStatusBarItem = window.createStatusBarItem(StatusBarAlignment.Right, 100);
this._environmentStatusBarItem.command = 'rest-client.switch-environment';
this._environmentStatusBarItem.text = initEnvironment.label;
this._environmentStatusBarItem.tooltip = 'Switch REST Client Environment';
this._environmentStatusBarItem.show();
this._restClientSettings = new RestClientSettings();

if (this._restClientSettings.showEnvironmentStatusBarItem) {
this._environmentStatusBarItem = window.createStatusBarItem(StatusBarAlignment.Right, 100);
this._environmentStatusBarItem.command = 'rest-client.switch-environment';
this._environmentStatusBarItem.text = initEnvironment.label;
this._environmentStatusBarItem.tooltip = 'Switch REST Client Environment';
this._environmentStatusBarItem.show();
}
}

@trace('Switch Environment')
Expand All @@ -46,7 +49,9 @@ export class EnvironmentController {
return;
}

this._environmentStatusBarItem.text = item.label;
if (this._restClientSettings.showEnvironmentStatusBarItem) {
this._environmentStatusBarItem.text = item.label;
}

await PersistUtility.saveEnvironment(item);
}
Expand Down
2 changes: 2 additions & 0 deletions src/models/configurationSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class RestClientSettings implements IRestClientSettings {
public proxyStrictSSL: boolean;
public rememberCookiesForSubsequentRequests: boolean;
public enableTelemetry: boolean;
public showEnvironmentStatusBarItem: boolean;
public excludeHostsForProxy: string[];
public fontSize?: number;
public fontFamily: string;
Expand Down Expand Up @@ -87,6 +88,7 @@ export class RestClientSettings implements IRestClientSettings {
this.proxy = httpSettings.get<string>('proxy', undefined);
this.proxyStrictSSL = httpSettings.get<boolean>('proxyStrictSSL', false);
this.enableTelemetry = httpSettings.get<boolean>('enableTelemetry', true);
this.showEnvironmentStatusBarItem = restClientSettings.get<boolean>('showEnvironmentStatusBarItem', true);
}

private getWorkspaceConfiguration(): WorkspaceConfiguration {
Expand Down

0 comments on commit cb5f963

Please sign in to comment.