diff --git a/src/commands/compile.ts b/src/commands/compile.ts index 9be22d8b..cebe6ef8 100644 --- a/src/commands/compile.ts +++ b/src/commands/compile.ts @@ -713,10 +713,25 @@ export async function importLocalFilesToServerSideFolder(wsFolderUri: vscode.Uri }) ) ).then((results) => results.map((result) => (result.status == "fulfilled" ? result.value : null)).filter(notNull)); - // The user is importing into a server-side folder, so fire source control hook - await new StudioActions().fireImportUserAction( - api, - docs.map((e) => e.name) + // The user is importing into a server-side folder, so fire the import list User Action + const docNames = docs.map((e) => e.name).join(","); + await new StudioActions().fireImportUserAction(api, docNames); + // Check the status of the documents to be imported and skip any that are read-only + await api.actionQuery("select * from %Atelier_v1_Utils.Extension_GetStatus(?)", [docNames]).then((data) => + data?.result?.content?.forEach((e) => { + if (!e.editable) { + const idx = docs.findIndex((d) => { + const nameSplit = d.name.split("."); + return e.name == `${nameSplit.slice(0, -1).join(".")}.${nameSplit.pop().toUpperCase()}`; + }); + if (idx != -1) { + docs.splice(idx, 1); + outputChannel.appendLine( + `Skipping '${e.name}' because it has been marked read-only by server-side source control.` + ); + } + } + }) ); // Import the files const rateLimiter = new RateLimiter(50); @@ -862,7 +877,7 @@ export async function importXMLFiles(): Promise { return items; }); // Prompt the user for documents to import - const docsToImport = await vscode.window.showQuickPick(quickPickItems, { + let docsToImport = await vscode.window.showQuickPick(quickPickItems, { canPickMany: true, ignoreFocusOut: true, title: `Select the documents to import into namespace '${api.ns}' on server '${api.serverId}'`, @@ -872,8 +887,28 @@ export async function importXMLFiles(): Promise { } const isIsfs = filesystemSchemas.includes(wsFolder.uri.scheme); if (isIsfs) { - // The user is importing into a server-side folder, so fire source control hook - await new StudioActions().fireImportUserAction(api, [...new Set(docsToImport.map((qpi) => qpi.label))]); + // The user is importing into a server-side folder + const docNames = [...new Set(docsToImport.map((qpi) => qpi.label))].join(","); + // Fire the import list User Action + await new StudioActions().fireImportUserAction(api, docNames); + // Check the status of the documents to be imported and skip any that are read-only + await api.actionQuery("select * from %Atelier_v1_Utils.Extension_GetStatus(?)", [docNames]).then((data) => { + const readOnly: string[] = []; + data?.result?.content?.forEach((e) => { + if (!e.editable) { + readOnly.push(e.name); + outputChannel.appendLine( + `Skipping '${e.name}' because it has been marked read-only by server-side source control.` + ); + } + }); + if (readOnly.length) { + docsToImport = docsToImport.filter((qpi) => { + const nameSplit = qpi.label.split("."); + return !readOnly.includes(`${nameSplit.slice(0, -1).join(".")}.${nameSplit.pop().toUpperCase()}`); + }); + } + }); } // Import the selected documents const filesToLoad: { file: string; content: string[]; selected: string[] }[] = filesToList.map((f) => { diff --git a/src/commands/export.ts b/src/commands/export.ts index 14f533d0..c632e255 100644 --- a/src/commands/export.ts +++ b/src/commands/export.ts @@ -352,7 +352,6 @@ export async function exportDocumentsToXMLFile(): Promise { quickPick.title = `Export the following ${documents.length > 1 ? `${documents.length} documents` : "document"}?`; quickPick.placeholder = "Click any item to confirm, or 'Escape' to cancel"; quickPick.ignoreFocusOut = true; - quickPick.onDidChangeSelection((e) => outputChannel.appendLine(JSON.stringify(e))); quickPick.onDidAccept(() => { resolve(true); quickPick.hide(); @@ -381,6 +380,7 @@ export async function exportDocumentsToXMLFile(): Promise { const xmlContent = await api.actionXMLExport(documents).then((data) => data.result.content); // Save the file await replaceFile(uri, xmlContent); + outputChannel.appendLine(`Exported to ${uri.scheme == "file" ? uri.fsPath : uri.toString(true)}`); } } catch (error) { handleError(error, "Error executing 'Export Documents to XML File...' command."); diff --git a/src/commands/studio.ts b/src/commands/studio.ts index bbd5d54e..6fb102b6 100644 --- a/src/commands/studio.ts +++ b/src/commands/studio.ts @@ -75,9 +75,9 @@ export class StudioActions { } /** Fire UserAction 6 on server `api` for document list `documents` */ - public async fireImportUserAction(api: AtelierAPI, documents: string[]): Promise { + public async fireImportUserAction(api: AtelierAPI, documents: string): Promise { this.api = api; - this.name = documents.join(","); + this.name = documents; return this.userAction( { id: OtherStudioAction.ImportListOfDocuments.toString(),