@@ -4,6 +4,7 @@ import vscode = require('vscode');
44import cp = require( 'child_process' ) ;
55import { Logger } from '../src/logging' ;
66import { LanguageClient , LanguageClientOptions , ServerOptions } from 'vscode-languageclient' ;
7+ import { ConnectionConfiguration } from './configuration' ;
78import { setupPuppetCommands } from '../src/commands/puppetcommands' ;
89import { setupPDKCommands } from '../src/commands/pdkcommands' ;
910import { reporter } from './telemetry/telemetry' ;
@@ -39,6 +40,7 @@ export interface IConnectionConfiguration {
3940export interface IConnectionManager {
4041 status : ConnectionStatus ;
4142 languageClient : LanguageClient ;
43+ showConnectionMenu ( ) ;
4244}
4345
4446export class ConnectionManager implements IConnectionManager {
@@ -78,7 +80,7 @@ export class ConnectionManager implements IConnectionManager {
7880 this . terminal = vscode . window . createTerminal ( 'Puppet PDK' ) ;
7981 this . terminal . processId . then (
8082 pid => {
81- console . log ( "pdk shell started, pid: " + pid ) ;
83+ this . logger . debug ( "pdk shell started, pid: " + pid ) ;
8284 } ) ;
8385 setupPDKCommands ( langID , this , this . extensionContext , this . logger , this . terminal ) ;
8486 this . extensionContext . subscriptions . push ( this . terminal ) ;
@@ -395,8 +397,7 @@ export class ConnectionManager implements IConnectionManager {
395397 if ( this . statusBarItem === undefined ) {
396398 this . statusBarItem = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Right , 1 ) ;
397399
398- // TODO: Add a command here to show the connection menu
399- // this.statusBarItem.command = this.ShowConnectionMenuCommandName;
400+ this . statusBarItem . command = messages . PuppetCommandStrings . PuppetShowConnectionMenuCommandId ;
400401 this . statusBarItem . show ( ) ;
401402 vscode . window . onDidChangeActiveTextEditor ( textEditor => {
402403 if ( textEditor === undefined || textEditor . document . languageId !== "puppet" ) {
@@ -409,6 +410,32 @@ export class ConnectionManager implements IConnectionManager {
409410 }
410411 }
411412
413+ public showConnectionMenu ( ) {
414+ var menuItems : ConnectionMenuItem [ ] = [ ] ;
415+
416+ let currentConnectionConfig = this . connectionConfiguration ;
417+
418+ menuItems . push (
419+ new ConnectionMenuItem (
420+ "Restart Current Puppet Session" ,
421+ ( ) => {
422+ let configuration = new ConnectionConfiguration ( this . extensionContext ) ;
423+ this . restartConnection ( configuration ) ;
424+ } ) ,
425+ )
426+
427+ menuItems . push (
428+ new ConnectionMenuItem (
429+ "Show Puppet Session Logs" ,
430+ ( ) => { this . logger . show ( ) ; } ) ,
431+ )
432+
433+ vscode
434+ . window
435+ . showQuickPick < ConnectionMenuItem > ( menuItems )
436+ . then ( ( selectedItem ) => { selectedItem . callback ( ) ; } ) ;
437+ }
438+
412439 private setConnectionStatus ( statusText : string , status : ConnectionStatus ) : void {
413440 // Set color and icon for 'Running' by default
414441 var statusIconText = "$(terminal) " ;
@@ -432,3 +459,11 @@ export class ConnectionManager implements IConnectionManager {
432459 this . setConnectionStatus ( "Starting Error" , ConnectionStatus . Failed ) ;
433460 }
434461}
462+
463+ class ConnectionMenuItem implements vscode . QuickPickItem {
464+ public description : string ;
465+
466+ constructor ( public readonly label : string , public readonly callback : ( ) => void = ( ) => { } )
467+ {
468+ }
469+ }
0 commit comments