@@ -12,6 +12,7 @@ import { isCSPFile } from "../providers/FileSystemProvider/FileSystemProvider";
1212import { notNull , outputChannel } from "../utils" ;
1313import { pickServerAndNamespace } from "./addServerNamespaceToWorkspace" ;
1414import { exportList } from "./export" ;
15+ import { OtherStudioAction , StudioActions } from "./studio" ;
1516
1617export interface ProjectItem {
1718 Name : string ;
@@ -137,6 +138,21 @@ export async function createProject(node: NodeBase | undefined, api?: AtelierAPI
137138 return ;
138139 }
139140
141+ // Technically a project is a "document", so tell the server that we created it
142+ try {
143+ const studioActions = new StudioActions ( ) ;
144+ await studioActions . fireProjectUserAction ( api , name , OtherStudioAction . CreatedNewDocument ) ;
145+ await studioActions . fireProjectUserAction ( api , name , OtherStudioAction . FirstTimeDocumentSave ) ;
146+ } catch ( error ) {
147+ let message = `Source control actions failed for project '${ name } '.` ;
148+ if ( error && error . errorText && error . errorText !== "" ) {
149+ outputChannel . appendLine ( "\n" + error . errorText ) ;
150+ outputChannel . show ( true ) ;
151+ message += " Check 'ObjectScript' output channel for details." ;
152+ }
153+ vscode . window . showErrorMessage ( message , "Dismiss" ) ;
154+ }
155+
140156 // Refresh the explorer
141157 projectsExplorerProvider . refresh ( ) ;
142158
@@ -179,6 +195,19 @@ export async function deleteProject(node: ProjectNode | undefined): Promise<any>
179195 return vscode . window . showErrorMessage ( message , "Dismiss" ) ;
180196 }
181197
198+ // Technically a project is a "document", so tell the server that we deleted it
199+ try {
200+ await new StudioActions ( ) . fireProjectUserAction ( api , project , OtherStudioAction . DeletedDocument ) ;
201+ } catch ( error ) {
202+ let message = `'DeletedDocument' source control action failed for project '${ project } '.` ;
203+ if ( error && error . errorText && error . errorText !== "" ) {
204+ outputChannel . appendLine ( "\n" + error . errorText ) ;
205+ outputChannel . show ( true ) ;
206+ message += " Check 'ObjectScript' output channel for details." ;
207+ }
208+ vscode . window . showErrorMessage ( message , "Dismiss" ) ;
209+ }
210+
182211 // Refresh the explorer
183212 projectsExplorerProvider . refresh ( ) ;
184213
@@ -706,6 +735,12 @@ export async function modifyProject(
706735 return ;
707736 }
708737 }
738+
739+ // Technically a project is a "document", so tell the server that we're opening it
740+ await new StudioActions ( ) . fireProjectUserAction ( api , project , OtherStudioAction . OpenedDocument ) . catch ( ( ) => {
741+ // Swallow error because showing it is more disruptive than using a potentially outdated project definition
742+ } ) ;
743+
709744 let items : ProjectItem [ ] = await api
710745 . actionQuery ( "SELECT Name, Type FROM %Studio.Project_ProjectItemsList(?,?) WHERE Type != 'GBL'" , [ project , "1" ] )
711746 . then ( ( data ) => data . result . content ) ;
@@ -862,6 +897,23 @@ export async function modifyProject(
862897 }
863898
864899 try {
900+ if ( add . length || remove . length ) {
901+ // Technically a project is a "document", so tell the server that we're editing it
902+ const studioActions = new StudioActions ( ) ;
903+ await studioActions . fireProjectUserAction ( api , project , OtherStudioAction . AttemptedEdit ) ;
904+ if ( studioActions . projectEditAnswer != "1" ) {
905+ // Don't perform the edit
906+ if ( studioActions . projectEditAnswer == "-1" ) {
907+ // Source control action failed
908+ vscode . window . showErrorMessage (
909+ `'AttemptedEdit' source control action failed for project '${ project } '. Check the 'ObjectScript' Output channel for details.` ,
910+ "Dismiss"
911+ ) ;
912+ }
913+ return ;
914+ }
915+ }
916+
865917 if ( remove . length ) {
866918 // Delete the obsolete items
867919 await api . actionQuery (
@@ -900,7 +952,7 @@ export async function modifyProject(
900952
901953 // Refresh the files explorer if there's an isfs folder for this project
902954 if ( node == undefined && isfsFolderForProject ( project , node ?? api . configName ) != - 1 ) {
903- await vscode . commands . executeCommand ( "workbench.files.action.refreshFilesExplorer" ) ;
955+ vscode . commands . executeCommand ( "workbench.files.action.refreshFilesExplorer" ) ;
904956 }
905957 }
906958}
@@ -1070,6 +1122,21 @@ export async function addIsfsFileToProject(
10701122
10711123 try {
10721124 if ( add . length ) {
1125+ // Technically a project is a "document", so tell the server that we're editing it
1126+ const studioActions = new StudioActions ( ) ;
1127+ await studioActions . fireProjectUserAction ( api , project , OtherStudioAction . AttemptedEdit ) ;
1128+ if ( studioActions . projectEditAnswer != "1" ) {
1129+ // Don't perform the edit
1130+ if ( studioActions . projectEditAnswer == "-1" ) {
1131+ // Source control action failed
1132+ vscode . window . showErrorMessage (
1133+ `'AttemptedEdit' source control action failed for project '${ project } '. Check the 'ObjectScript' Output channel for details.` ,
1134+ "Dismiss"
1135+ ) ;
1136+ }
1137+ return ;
1138+ }
1139+
10731140 // Add any new items
10741141 await api . actionQuery (
10751142 `INSERT INTO %Studio.ProjectItem (Project,Name,Type) SELECT * FROM (${ add
0 commit comments