@@ -713,10 +713,25 @@ export async function importLocalFilesToServerSideFolder(wsFolderUri: vscode.Uri
713
713
} )
714
714
)
715
715
) . then ( ( results ) => results . map ( ( result ) => ( result . status == "fulfilled" ? result . value : null ) ) . filter ( notNull ) ) ;
716
- // The user is importing into a server-side folder, so fire source control hook
717
- await new StudioActions ( ) . fireImportUserAction (
718
- api ,
719
- docs . map ( ( e ) => e . name )
716
+ // The user is importing into a server-side folder, so fire the import list User Action
717
+ const docNames = docs . map ( ( e ) => e . name ) . join ( "," ) ;
718
+ await new StudioActions ( ) . fireImportUserAction ( api , docNames ) ;
719
+ // Check the status of the documents to be imported and skip any that are read-only
720
+ await api . actionQuery ( "select * from %Atelier_v1_Utils.Extension_GetStatus(?)" , [ docNames ] ) . then ( ( data ) =>
721
+ data ?. result ?. content ?. forEach ( ( e ) => {
722
+ if ( ! e . editable ) {
723
+ const idx = docs . findIndex ( ( d ) => {
724
+ const nameSplit = d . name . split ( "." ) ;
725
+ return e . name == `${ nameSplit . slice ( 0 , - 1 ) . join ( "." ) } .${ nameSplit . pop ( ) . toUpperCase ( ) } ` ;
726
+ } ) ;
727
+ if ( idx != - 1 ) {
728
+ docs . splice ( idx , 1 ) ;
729
+ outputChannel . appendLine (
730
+ `Skipping '${ e . name } ' because it has been marked read-only by server-side source control.`
731
+ ) ;
732
+ }
733
+ }
734
+ } )
720
735
) ;
721
736
// Import the files
722
737
const rateLimiter = new RateLimiter ( 50 ) ;
@@ -862,7 +877,7 @@ export async function importXMLFiles(): Promise<any> {
862
877
return items ;
863
878
} ) ;
864
879
// Prompt the user for documents to import
865
- const docsToImport = await vscode . window . showQuickPick ( quickPickItems , {
880
+ let docsToImport = await vscode . window . showQuickPick ( quickPickItems , {
866
881
canPickMany : true ,
867
882
ignoreFocusOut : true ,
868
883
title : `Select the documents to import into namespace '${ api . ns } ' on server '${ api . serverId } '` ,
@@ -872,8 +887,28 @@ export async function importXMLFiles(): Promise<any> {
872
887
}
873
888
const isIsfs = filesystemSchemas . includes ( wsFolder . uri . scheme ) ;
874
889
if ( isIsfs ) {
875
- // The user is importing into a server-side folder, so fire source control hook
876
- await new StudioActions ( ) . fireImportUserAction ( api , [ ...new Set ( docsToImport . map ( ( qpi ) => qpi . label ) ) ] ) ;
890
+ // The user is importing into a server-side folder
891
+ const docNames = [ ...new Set ( docsToImport . map ( ( qpi ) => qpi . label ) ) ] . join ( "," ) ;
892
+ // Fire the import list User Action
893
+ await new StudioActions ( ) . fireImportUserAction ( api , docNames ) ;
894
+ // Check the status of the documents to be imported and skip any that are read-only
895
+ await api . actionQuery ( "select * from %Atelier_v1_Utils.Extension_GetStatus(?)" , [ docNames ] ) . then ( ( data ) => {
896
+ const readOnly : string [ ] = [ ] ;
897
+ data ?. result ?. content ?. forEach ( ( e ) => {
898
+ if ( ! e . editable ) {
899
+ readOnly . push ( e . name ) ;
900
+ outputChannel . appendLine (
901
+ `Skipping '${ e . name } ' because it has been marked read-only by server-side source control.`
902
+ ) ;
903
+ }
904
+ } ) ;
905
+ if ( readOnly . length ) {
906
+ docsToImport = docsToImport . filter ( ( qpi ) => {
907
+ const nameSplit = qpi . label . split ( "." ) ;
908
+ return ! readOnly . includes ( `${ nameSplit . slice ( 0 , - 1 ) . join ( "." ) } .${ nameSplit . pop ( ) . toUpperCase ( ) } ` ) ;
909
+ } ) ;
910
+ }
911
+ } ) ;
877
912
}
878
913
// Import the selected documents
879
914
const filesToLoad : { file : string ; content : string [ ] ; selected : string [ ] } [ ] = filesToList . map ( ( f ) => {
0 commit comments