@@ -9,6 +9,7 @@ import { RoutineNode } from "../explorer/models/routineNode";
9
9
import { importAndCompile } from "./compile" ;
10
10
import { ProjectNode } from "../explorer/models/projectNode" ;
11
11
import { openCustomEditors } from "../providers/RuleEditorProvider" ;
12
+ import { UserAction } from "../api/atelier" ;
12
13
13
14
export let documentBeingProcessed : vscode . TextDocument = null ;
14
15
@@ -119,9 +120,8 @@ export class StudioActions {
119
120
) ;
120
121
}
121
122
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 ;
125
125
const { target, errorText } = userAction ;
126
126
if ( errorText !== "" ) {
127
127
outputChannel . appendLine ( errorText ) ;
@@ -295,14 +295,18 @@ export class StudioActions {
295
295
? [ type . toString ( ) , action . id , this . name , answer , msg ]
296
296
: [ type . toString ( ) , action . id , this . name , selectedText ] ;
297
297
298
+ if ( config ( ) . studioActionDebugOutput ) {
299
+ outputChannel . appendLine ( `${ query . slice ( 0 , query . indexOf ( "(" ) ) } (${ JSON . stringify ( parameters ) . slice ( 1 , - 1 ) } )` ) ;
300
+ }
301
+
298
302
return vscode . window . withProgress (
299
303
{
300
304
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 } ` ,
303
307
} ,
304
- ( ) => {
305
- return new Promise ( ( resolve , reject ) => {
308
+ ( ) =>
309
+ new Promise ( ( resolve , reject ) => {
306
310
this . api
307
311
. actionQuery ( query , parameters )
308
312
. then ( async ( data ) => {
@@ -313,22 +317,18 @@ export class StudioActions {
313
317
outputConsole ( data . console ) ;
314
318
}
315
319
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" ;
317
322
return ;
318
323
}
319
- const actionToProcess = data . result . content . pop ( ) ;
324
+ const actionToProcess : UserAction = data . result . content . pop ( ) ;
320
325
321
326
if ( actionToProcess . reload ) {
322
327
// Avoid the reload triggering the edit listener here
323
328
suppressEditListenerMap . set ( this . uri . toString ( ) , true ) ;
324
329
await vscode . commands . executeCommand ( "workbench.action.files.revert" , this . uri ) ;
325
330
}
326
331
327
- // CSP pages should not have a progress bar
328
- if ( actionToProcess . action === 2 ) {
329
- resolve ( ) ;
330
- }
331
-
332
332
const attemptedEditLabel = getOtherStudioActionLabel ( OtherStudioAction . AttemptedEdit ) ;
333
333
if ( afterUserAction && actionToProcess . errorText !== "" ) {
334
334
if ( action . label === attemptedEditLabel ) {
@@ -342,7 +342,7 @@ export class StudioActions {
342
342
}
343
343
}
344
344
outputChannel . appendLine ( actionToProcess . errorText ) ;
345
- outputChannel . show ( ) ;
345
+ outputChannel . show ( true ) ;
346
346
}
347
347
if ( actionToProcess && ! afterUserAction ) {
348
348
const answer = await this . processUserAction ( actionToProcess ) ;
@@ -377,11 +377,10 @@ export class StudioActions {
377
377
if ( err . errorText && err . errorText !== "" ) {
378
378
outputChannel . appendLine ( "\n" + err . errorText ) ;
379
379
}
380
- outputChannel . show ( ) ;
380
+ outputChannel . show ( true ) ;
381
381
reject ( ) ;
382
382
} ) ;
383
- } ) ;
384
- }
383
+ } )
385
384
) ;
386
385
}
387
386
@@ -438,8 +437,7 @@ export class StudioActions {
438
437
. then ( ( action ) => this . userAction ( action ) ) ;
439
438
}
440
439
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 {
443
441
const actionObject = {
444
442
id : action . toString ( ) ,
445
443
label : getOtherStudioActionLabel ( action ) ,
@@ -501,7 +499,8 @@ export class StudioActions {
501
499
return this . api
502
500
. actionQuery ( "SELECT %Atelier_v1_Utils.Extension_ExtensionEnabled() AS Enabled" , [ ] )
503
501
. 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"
505
504
}
506
505
507
506
public getServerInfo ( ) : { server : string ; namespace : string } {
@@ -568,15 +567,17 @@ export async function _contextMenu(sourceControl: boolean, node: PackageNode | C
568
567
}
569
568
}
570
569
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 > {
573
575
if ( vscode . workspace . getConfiguration ( "objectscript.serverSourceControl" , uri ) ?. get ( "disableOtherActionTriggers" ) ) {
574
576
return ;
575
577
}
576
578
const studioActions = new StudioActions ( uri ) ;
577
579
return (
578
580
studioActions &&
579
- ( await studioActions . isSourceControlEnabled ( ) ) &&
580
581
! openCustomEditors . includes ( uri ?. toString ( ) ) && // The custom editor will handle all server-side source control interactions
581
582
studioActions . fireOtherStudioAction ( action , userAction )
582
583
) ;
0 commit comments