Skip to content

XML import/export issues #1616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 42 additions & 7 deletions src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -862,7 +877,7 @@ export async function importXMLFiles(): Promise<any> {
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}'`,
Expand All @@ -872,8 +887,28 @@ export async function importXMLFiles(): Promise<any> {
}
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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ export async function exportDocumentsToXMLFile(): Promise<void> {
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();
Expand Down Expand Up @@ -381,6 +380,7 @@ export async function exportDocumentsToXMLFile(): Promise<void> {
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.");
Expand Down
4 changes: 2 additions & 2 deletions src/commands/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
public async fireImportUserAction(api: AtelierAPI, documents: string): Promise<void> {
this.api = api;
this.name = documents.join(",");
this.name = documents;
return this.userAction(
{
id: OtherStudioAction.ImportListOfDocuments.toString(),
Expand Down