@@ -12,6 +12,7 @@ import { isCSPFile } from "../providers/FileSystemProvider/FileSystemProvider";
12
12
import { notNull , outputChannel } from "../utils" ;
13
13
import { pickServerAndNamespace } from "./addServerNamespaceToWorkspace" ;
14
14
import { exportList } from "./export" ;
15
+ import { OtherStudioAction , StudioActions } from "./studio" ;
15
16
16
17
export interface ProjectItem {
17
18
Name : string ;
@@ -137,6 +138,20 @@ export async function createProject(node: NodeBase | undefined, api?: AtelierAPI
137
138
return ;
138
139
}
139
140
141
+ // Technically a project is a "document", so tell the server that we created it
142
+ try {
143
+ await new StudioActions ( ) . fireProjectUserAction ( api , name , OtherStudioAction . CreatedNewDocument ) ;
144
+ await new StudioActions ( ) . fireProjectUserAction ( api , name , OtherStudioAction . FirstTimeDocumentSave ) ;
145
+ } catch ( error ) {
146
+ let message = `Source control actions failed for project '${ name } '.` ;
147
+ if ( error && error . errorText && error . errorText !== "" ) {
148
+ outputChannel . appendLine ( "\n" + error . errorText ) ;
149
+ outputChannel . show ( true ) ;
150
+ message += " Check 'ObjectScript' output channel for details." ;
151
+ }
152
+ return vscode . window . showErrorMessage ( message , "Dismiss" ) ;
153
+ }
154
+
140
155
// Refresh the explorer
141
156
projectsExplorerProvider . refresh ( ) ;
142
157
@@ -179,6 +194,19 @@ export async function deleteProject(node: ProjectNode | undefined): Promise<any>
179
194
return vscode . window . showErrorMessage ( message , "Dismiss" ) ;
180
195
}
181
196
197
+ // Technically a project is a "document", so tell the server that we deleted it
198
+ try {
199
+ await new StudioActions ( ) . fireProjectUserAction ( api , project , OtherStudioAction . DeletedDocument ) ;
200
+ } catch ( error ) {
201
+ let message = `'DeletedDocument' source control action failed for project '${ project } '.` ;
202
+ if ( error && error . errorText && error . errorText !== "" ) {
203
+ outputChannel . appendLine ( "\n" + error . errorText ) ;
204
+ outputChannel . show ( true ) ;
205
+ message += " Check 'ObjectScript' output channel for details." ;
206
+ }
207
+ return vscode . window . showErrorMessage ( message , "Dismiss" ) ;
208
+ }
209
+
182
210
// Refresh the explorer
183
211
projectsExplorerProvider . refresh ( ) ;
184
212
@@ -706,6 +734,20 @@ export async function modifyProject(
706
734
return ;
707
735
}
708
736
}
737
+
738
+ // Technically a project is a "document", so tell the server that we're opening it
739
+ try {
740
+ await new StudioActions ( ) . fireProjectUserAction ( api , project , OtherStudioAction . OpenedDocument ) ;
741
+ } catch ( error ) {
742
+ let message = `'OpenedDocument' source control action failed for project '${ project } '.` ;
743
+ if ( error && error . errorText && error . errorText !== "" ) {
744
+ outputChannel . appendLine ( "\n" + error . errorText ) ;
745
+ outputChannel . show ( true ) ;
746
+ message += " Check 'ObjectScript' output channel for details." ;
747
+ }
748
+ return vscode . window . showErrorMessage ( message , "Dismiss" ) ;
749
+ }
750
+
709
751
let items : ProjectItem [ ] = await api
710
752
. actionQuery ( "SELECT Name, Type FROM %Studio.Project_ProjectItemsList(?,?) WHERE Type != 'GBL'" , [ project , "1" ] )
711
753
. then ( ( data ) => data . result . content ) ;
@@ -862,6 +904,23 @@ export async function modifyProject(
862
904
}
863
905
864
906
try {
907
+ if ( add . length || remove . length ) {
908
+ // Technically a project is a "document", so tell the server that we're editing it
909
+ const studioActions = new StudioActions ( ) ;
910
+ await studioActions . fireProjectUserAction ( api , project , OtherStudioAction . AttemptedEdit ) ;
911
+ if ( studioActions . projectEditAnswer != "1" ) {
912
+ // Don't perform the edit
913
+ if ( studioActions . projectEditAnswer == "-1" ) {
914
+ // Source control action failed
915
+ vscode . window . showErrorMessage (
916
+ `'AttemptedEdit' source control action failed for project '${ project } '. Check the 'ObjectScript' Output channel for details.` ,
917
+ "Dismiss"
918
+ ) ;
919
+ }
920
+ return ;
921
+ }
922
+ }
923
+
865
924
if ( remove . length ) {
866
925
// Delete the obsolete items
867
926
await api . actionQuery (
@@ -900,7 +959,7 @@ export async function modifyProject(
900
959
901
960
// Refresh the files explorer if there's an isfs folder for this project
902
961
if ( node == undefined && isfsFolderForProject ( project , node ?? api . configName ) != - 1 ) {
903
- await vscode . commands . executeCommand ( "workbench.files.action.refreshFilesExplorer" ) ;
962
+ vscode . commands . executeCommand ( "workbench.files.action.refreshFilesExplorer" ) ;
904
963
}
905
964
}
906
965
}
@@ -1070,6 +1129,21 @@ export async function addIsfsFileToProject(
1070
1129
1071
1130
try {
1072
1131
if ( add . length ) {
1132
+ // Technically a project is a "document", so tell the server that we're editing it
1133
+ const studioActions = new StudioActions ( ) ;
1134
+ await studioActions . fireProjectUserAction ( api , project , OtherStudioAction . AttemptedEdit ) ;
1135
+ if ( studioActions . projectEditAnswer != "1" ) {
1136
+ // Don't perform the edit
1137
+ if ( studioActions . projectEditAnswer == "-1" ) {
1138
+ // Source control action failed
1139
+ vscode . window . showErrorMessage (
1140
+ `'AttemptedEdit' source control action failed for project '${ project } '. Check the 'ObjectScript' Output channel for details.` ,
1141
+ "Dismiss"
1142
+ ) ;
1143
+ }
1144
+ return ;
1145
+ }
1146
+
1073
1147
// Add any new items
1074
1148
await api . actionQuery (
1075
1149
`INSERT INTO %Studio.ProjectItem (Project,Name,Type) SELECT * FROM (${ add
0 commit comments