@@ -9,6 +9,7 @@ import { RoutineNode } from "../explorer/models/routineNode";
99import { importAndCompile } from "./compile" ;
1010import { ProjectNode } from "../explorer/models/projectNode" ;
1111import { openCustomEditors } from "../providers/RuleEditorProvider" ;
12+ import { UserAction } from "../api/atelier" ;
1213
1314export let documentBeingProcessed : vscode . TextDocument = null ;
1415
@@ -119,9 +120,8 @@ export class StudioActions {
119120 ) ;
120121 }
121122
122- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
123- public processUserAction ( userAction ) : Thenable < any > {
124- const serverAction = parseInt ( userAction . action || 0 , 10 ) ;
123+ public processUserAction ( userAction : UserAction ) : Thenable < any > {
124+ const serverAction = userAction . action ;
125125 const { target, errorText } = userAction ;
126126 if ( errorText !== "" ) {
127127 outputChannel . appendLine ( errorText ) ;
@@ -295,14 +295,18 @@ export class StudioActions {
295295 ? [ type . toString ( ) , action . id , this . name , answer , msg ]
296296 : [ type . toString ( ) , action . id , this . name , selectedText ] ;
297297
298+ if ( config ( ) . studioActionDebugOutput ) {
299+ outputChannel . appendLine ( `${ query . slice ( 0 , query . indexOf ( "(" ) ) } (${ JSON . stringify ( parameters ) . slice ( 1 , - 1 ) } )` ) ;
300+ }
301+
298302 return vscode . window . withProgress (
299303 {
300304 cancellable : false ,
301- location : vscode . ProgressLocation . Notification ,
302- title : `Executing ${ afterUserAction ? "AfterUserAction " : "UserAction" } : ${ action . label } ` ,
305+ location : vscode . ProgressLocation . Window ,
306+ title : `Executing ${ afterUserAction ? "After " : "" } UserAction : ${ action . label } ` ,
303307 } ,
304- ( ) => {
305- return new Promise ( ( resolve , reject ) => {
308+ ( ) =>
309+ new Promise ( ( resolve , reject ) => {
306310 this . api
307311 . actionQuery ( query , parameters )
308312 . then ( async ( data ) => {
@@ -313,22 +317,18 @@ export class StudioActions {
313317 outputConsole ( data . console ) ;
314318 }
315319 if ( ! data . result . content . length ) {
316- // nothing to-do, just ignore it
320+ // Nothing to do. Most likely no source control class is enabled.
321+ this . projectEditAnswer = "1" ;
317322 return ;
318323 }
319- const actionToProcess = data . result . content . pop ( ) ;
324+ const actionToProcess : UserAction = data . result . content . pop ( ) ;
320325
321326 if ( actionToProcess . reload ) {
322327 // Avoid the reload triggering the edit listener here
323328 suppressEditListenerMap . set ( this . uri . toString ( ) , true ) ;
324329 await vscode . commands . executeCommand ( "workbench.action.files.revert" , this . uri ) ;
325330 }
326331
327- // CSP pages should not have a progress bar
328- if ( actionToProcess . action === 2 ) {
329- resolve ( ) ;
330- }
331-
332332 const attemptedEditLabel = getOtherStudioActionLabel ( OtherStudioAction . AttemptedEdit ) ;
333333 if ( afterUserAction && actionToProcess . errorText !== "" ) {
334334 if ( action . label === attemptedEditLabel ) {
@@ -342,7 +342,7 @@ export class StudioActions {
342342 }
343343 }
344344 outputChannel . appendLine ( actionToProcess . errorText ) ;
345- outputChannel . show ( ) ;
345+ outputChannel . show ( true ) ;
346346 }
347347 if ( actionToProcess && ! afterUserAction ) {
348348 const answer = await this . processUserAction ( actionToProcess ) ;
@@ -377,11 +377,10 @@ export class StudioActions {
377377 if ( err . errorText && err . errorText !== "" ) {
378378 outputChannel . appendLine ( "\n" + err . errorText ) ;
379379 }
380- outputChannel . show ( ) ;
380+ outputChannel . show ( true ) ;
381381 reject ( ) ;
382382 } ) ;
383- } ) ;
384- }
383+ } )
385384 ) ;
386385 }
387386
@@ -438,8 +437,7 @@ export class StudioActions {
438437 . then ( ( action ) => this . userAction ( action ) ) ;
439438 }
440439
441- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
442- public fireOtherStudioAction ( action : OtherStudioAction , userAction ?) : void {
440+ public fireOtherStudioAction ( action : OtherStudioAction , userAction ?: UserAction ) : void {
443441 const actionObject = {
444442 id : action . toString ( ) ,
445443 label : getOtherStudioActionLabel ( action ) ,
@@ -501,7 +499,8 @@ export class StudioActions {
501499 return this . api
502500 . actionQuery ( "SELECT %Atelier_v1_Utils.Extension_ExtensionEnabled() AS Enabled" , [ ] )
503501 . then ( ( data ) => data . result . content )
504- . then ( ( content ) => ( content && content . length ? content [ 0 ] . Enabled : false ) ) ;
502+ . then ( ( content ) => ( content && content . length ? content [ 0 ] ?. Enabled ?? false : false ) )
503+ . catch ( ( ) => false ) ; // Treat any errors as "no source control"
505504 }
506505
507506 public getServerInfo ( ) : { server : string ; namespace : string } {
@@ -568,15 +567,17 @@ export async function _contextMenu(sourceControl: boolean, node: PackageNode | C
568567 }
569568}
570569
571- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
572- export async function fireOtherStudioAction ( action : OtherStudioAction , uri ?: vscode . Uri , userAction ?) : Promise < void > {
570+ export async function fireOtherStudioAction (
571+ action : OtherStudioAction ,
572+ uri ?: vscode . Uri ,
573+ userAction ?: UserAction
574+ ) : Promise < void > {
573575 if ( vscode . workspace . getConfiguration ( "objectscript.serverSourceControl" , uri ) ?. get ( "disableOtherActionTriggers" ) ) {
574576 return ;
575577 }
576578 const studioActions = new StudioActions ( uri ) ;
577579 return (
578580 studioActions &&
579- ( await studioActions . isSourceControlEnabled ( ) ) &&
580581 ! openCustomEditors . includes ( uri ?. toString ( ) ) && // The custom editor will handle all server-side source control interactions
581582 studioActions . fireOtherStudioAction ( action , userAction )
582583 ) ;
0 commit comments