Skip to content

Commit 479f6b6

Browse files
jpogranglennsarti
authored andcommitted
(GH-136) Add restart languageserver and show logs to command palette
This the Restart Current Session and Show Connection logs to the command palette and the click menu on the Puppet status now calls these commands directly.
1 parent e2b2ab6 commit 479f6b6

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

client/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
],
3939
"activationEvents": [
4040
"onLanguage:puppet",
41+
"onCommand:extension.puppetShowConnectionMenu",
4142
"onCommand:extension.puppetLint",
4243
"onCommand:extension.puppetParserValidate",
4344
"onCommand:extension.puppetShowNodeGraphToSide",
@@ -87,6 +88,16 @@
8788
}
8889
],
8990
"commands": [
91+
{
92+
"command": "extension.puppetRestartSession",
93+
"category": "Puppet",
94+
"title": "Restart Current Session"
95+
},
96+
{
97+
"command": "extension.puppetShowConnectionLogs",
98+
"category": "Puppet",
99+
"title": "Show Connection Logs"
100+
},
90101
{
91102
"command": "extension.pdkNewModule",
92103
"category": "Puppet",

client/src/commands/puppetcommands.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ export function setupPuppetCommands(langID:string, connManager:IConnectionManage
2424
() => { connManager.showConnectionMenu(); }
2525
));
2626

27+
ctx.subscriptions.push(vscode.commands.registerCommand(messages.PuppetCommandStrings.PuppetShowConnectionLogsCommandId,
28+
() => { connManager.showLogger(); }
29+
));
30+
31+
ctx.subscriptions.push(vscode.commands.registerCommand(messages.PuppetCommandStrings.PuppetRestartSessionCommandId,
32+
() => { connManager.restartConnection(); }
33+
));
34+
2735
const contentProvider = new PuppetNodeGraphContentProvider(ctx, connManager);
2836
const contentProviderRegistration = vscode.workspace.registerTextDocumentContentProvider(langID, contentProvider);
2937

client/src/connection.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export interface IConnectionManager {
4141
status: ConnectionStatus;
4242
languageClient: LanguageClient;
4343
showConnectionMenu();
44+
showLogger();
45+
restartConnection(connectionConfig?: IConnectionConfiguration);
4446
}
4547

4648
export class ConnectionManager implements IConnectionManager {
@@ -60,6 +62,9 @@ export class ConnectionManager implements IConnectionManager {
6062
public get languageClient() : LanguageClient {
6163
return this.languageServerClient;
6264
}
65+
public showLogger() {
66+
this.logger.show()
67+
}
6368

6469
constructor(context: vscode.ExtensionContext, logger: Logger) {
6570
this.logger = logger;
@@ -387,10 +392,12 @@ export class ConnectionManager implements IConnectionManager {
387392
});
388393
}
389394

390-
391-
private restartConnection(connectionConfig?: IConnectionConfiguration) {
392-
this.stop();
393-
this.start(connectionConfig);
395+
public restartConnection(connectionConfig?: IConnectionConfiguration) {
396+
if (connectionConfig == undefined) {
397+
connectionConfig = new ConnectionConfiguration(this.extensionContext);
398+
}
399+
this.stop();
400+
this.start(connectionConfig);
394401
}
395402

396403
private createStatusBarItem() {
@@ -413,21 +420,16 @@ export class ConnectionManager implements IConnectionManager {
413420
public showConnectionMenu() {
414421
var menuItems: ConnectionMenuItem[] = [];
415422

416-
let currentConnectionConfig = this.connectionConfiguration;
417-
418423
menuItems.push(
419424
new ConnectionMenuItem(
420425
"Restart Current Puppet Session",
421-
() => {
422-
let configuration = new ConnectionConfiguration(this.extensionContext);
423-
this.restartConnection(configuration);
424-
}),
426+
() => { vscode.commands.executeCommand(messages.PuppetCommandStrings.PuppetRestartSessionCommandId); }),
425427
)
426428

427429
menuItems.push(
428430
new ConnectionMenuItem(
429431
"Show Puppet Session Logs",
430-
() => { this.logger.show(); }),
432+
() => { vscode.commands.executeCommand(messages.PuppetCommandStrings.PuppetShowConnectionLogsCommandId); }),
431433
)
432434

433435
vscode

client/src/messages.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export class PuppetCommandStrings{
4141
static PuppetResourceCommandId:string = 'extension.puppetResource';
4242
static PuppetNodeGraphToTheSideCommandId = 'extension.puppetShowNodeGraphToSide';
4343
static PuppetShowConnectionMenuCommandId = 'extension.puppetShowConnectionMenu';
44+
static PuppetShowConnectionLogsCommandId = 'extension.puppetShowConnectionLogs';
45+
static PuppetRestartSessionCommandId = 'extension.puppetRestartSession';
4446
}
4547

4648
export class PDKCommandStrings {

0 commit comments

Comments
 (0)