@@ -318,9 +318,11 @@ class StudioActions {
318318 . then ( ( ) => resolve ( ) )
319319 . catch ( ( err ) => {
320320 outputChannel . appendLine (
321- `Executing Studio Action "${ action . label } " on ${ this . api . config . host } :${ this . api . config . port } [${
322- this . api . config . ns
323- } ] failed${ err . errorText && err . errorText !== "" ? " with the following error:" : "." } `
321+ `Executing Studio Action "${ action . label } " on ${ this . api . config . host } :${ this . api . config . port } ${
322+ this . api . config . pathPrefix
323+ } [${ this . api . config . ns } ] failed${
324+ err . errorText && err . errorText !== "" ? " with the following error:" : "."
325+ } `
324326 ) ;
325327 if ( err . errorText && err . errorText !== "" ) {
326328 outputChannel . appendLine ( "\n" + err . errorText ) ;
@@ -443,6 +445,20 @@ class StudioActions {
443445 }
444446 }
445447 }
448+
449+ public async isSourceControlEnabled ( ) : Promise < boolean > {
450+ return this . api
451+ . actionQuery ( "SELECT %Atelier_v1_Utils.Extension_ExtensionEnabled() AS Enabled" , [ ] )
452+ . then ( ( data ) => data . result . content )
453+ . then ( ( content ) => ( content && content . length ? content [ 0 ] . Enabled : false ) ) ;
454+ }
455+
456+ public getServerInfo ( ) {
457+ return {
458+ server : `${ this . api . config . host } :${ this . api . config . port } ${ this . api . config . pathPrefix } ` ,
459+ namespace : this . api . config . ns ,
460+ } ;
461+ }
446462}
447463
448464export async function mainCommandMenu ( uri ?: vscode . Uri ) : Promise < void > {
@@ -459,7 +475,17 @@ async function _mainMenu(sourceControl: boolean, uri?: vscode.Uri): Promise<void
459475 return ;
460476 }
461477 const studioActions = new StudioActions ( uri ) ;
462- return studioActions && studioActions . getMenu ( StudioMenuType . Main , sourceControl ) ;
478+ if ( studioActions ) {
479+ if ( await studioActions . isSourceControlEnabled ( ) ) {
480+ return studioActions . getMenu ( StudioMenuType . Main , sourceControl ) ;
481+ } else {
482+ const serverInfo = studioActions . getServerInfo ( ) ;
483+ vscode . window . showInformationMessage (
484+ `No source control class is configured for namespace "${ serverInfo . namespace } " on server ${ serverInfo . server } .` ,
485+ "Dismiss"
486+ ) ;
487+ }
488+ }
463489}
464490
465491export async function contextCommandMenu ( node : PackageNode | ClassNode | RoutineNode ) : Promise < void > {
@@ -476,7 +502,17 @@ export async function _contextMenu(sourceControl: boolean, node: PackageNode | C
476502 return ;
477503 }
478504 const studioActions = new StudioActions ( nodeOrUri ) ;
479- return studioActions && studioActions . getMenu ( StudioMenuType . Context , sourceControl ) ;
505+ if ( studioActions ) {
506+ if ( await studioActions . isSourceControlEnabled ( ) ) {
507+ return studioActions . getMenu ( StudioMenuType . Context , sourceControl ) ;
508+ } else {
509+ const serverInfo = studioActions . getServerInfo ( ) ;
510+ vscode . window . showInformationMessage (
511+ `No source control class is configured for namespace "${ serverInfo . namespace } " on server ${ serverInfo . server } .` ,
512+ "Dismiss"
513+ ) ;
514+ }
515+ }
480516}
481517
482518// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
@@ -485,5 +521,9 @@ export async function fireOtherStudioAction(action: OtherStudioAction, uri?: vsc
485521 return ;
486522 }
487523 const studioActions = new StudioActions ( uri ) ;
488- return studioActions && studioActions . fireOtherStudioAction ( action , userAction ) ;
524+ return (
525+ studioActions &&
526+ ( await studioActions . isSourceControlEnabled ( ) ) &&
527+ studioActions . fireOtherStudioAction ( action , userAction )
528+ ) ;
489529}
0 commit comments