@@ -318,9 +318,11 @@ class StudioActions {
318
318
. then ( ( ) => resolve ( ) )
319
319
. catch ( ( err ) => {
320
320
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
+ } `
324
326
) ;
325
327
if ( err . errorText && err . errorText !== "" ) {
326
328
outputChannel . appendLine ( "\n" + err . errorText ) ;
@@ -443,6 +445,20 @@ class StudioActions {
443
445
}
444
446
}
445
447
}
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
+ }
446
462
}
447
463
448
464
export async function mainCommandMenu ( uri ?: vscode . Uri ) : Promise < void > {
@@ -459,7 +475,17 @@ async function _mainMenu(sourceControl: boolean, uri?: vscode.Uri): Promise<void
459
475
return ;
460
476
}
461
477
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
+ }
463
489
}
464
490
465
491
export async function contextCommandMenu ( node : PackageNode | ClassNode | RoutineNode ) : Promise < void > {
@@ -476,7 +502,17 @@ export async function _contextMenu(sourceControl: boolean, node: PackageNode | C
476
502
return ;
477
503
}
478
504
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
+ }
480
516
}
481
517
482
518
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
@@ -485,5 +521,9 @@ export async function fireOtherStudioAction(action: OtherStudioAction, uri?: vsc
485
521
return ;
486
522
}
487
523
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
+ ) ;
489
529
}
0 commit comments