diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/tree/folder/script-folder.server.data-source.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/tree/folder/script-folder.server.data-source.ts index 6b99454ccc..cb67d20c35 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/tree/folder/script-folder.server.data-source.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/tree/folder/script-folder.server.data-source.ts @@ -33,11 +33,12 @@ export class UmbScriptFolderServerDataSource implements UmbFolderDataSource { if (!unique) throw new Error('Unique is missing'); const path = this.#serverPathUniqueSerializer.toServerPath(unique); + if (!path) throw new Error('Cannot read script folder without a path'); const { data, error } = await tryExecuteAndNotify( this.#host, ScriptResource.getScriptFolderByPath({ - path, + path: encodeURIComponent(path), }), ); @@ -67,9 +68,7 @@ export class UmbScriptFolderServerDataSource implements UmbFolderDataSource { const parentPath = new UmbServerPathUniqueSerializer().toServerPath(args.parentUnique); const requestBody: CreateScriptFolderRequestModel = { - parent: { - path: parentPath, - }, + parent: parentPath ? { path: parentPath } : null, name: args.name, }; @@ -81,8 +80,9 @@ export class UmbScriptFolderServerDataSource implements UmbFolderDataSource { ); if (data) { - const newPath = this.#serverPathUniqueSerializer.toUnique(data); - return this.read(newPath); + const newPath = decodeURIComponent(data); + const newPathUnique = this.#serverPathUniqueSerializer.toUnique(newPath); + return this.read(newPathUnique); } return { error }; @@ -98,11 +98,12 @@ export class UmbScriptFolderServerDataSource implements UmbFolderDataSource { if (!unique) throw new Error('Unique is missing'); const path = this.#serverPathUniqueSerializer.toServerPath(unique); + if (!path) throw new Error('Cannot delete script folder without a path'); return tryExecuteAndNotify( this.#host, ScriptResource.deleteScriptFolderByPath({ - path, + path: encodeURIComponent(path), }), ); } diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/tree/folder/stylesheet-folder.server.data-source.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/tree/folder/stylesheet-folder.server.data-source.ts index 3c21c2048c..7fccb37ebf 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/tree/folder/stylesheet-folder.server.data-source.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/tree/folder/stylesheet-folder.server.data-source.ts @@ -33,11 +33,12 @@ export class UmbStylesheetFolderServerDataSource implements UmbFolderDataSource if (!unique) throw new Error('Unique is missing'); const path = this.#serverPathUniqueSerializer.toServerPath(unique); + if (!path) throw new Error('Cannot read stylesheet folder without a path'); const { data, error } = await tryExecuteAndNotify( this.#host, StylesheetResource.getStylesheetFolderByPath({ - path, + path: encodeURIComponent(path), }), ); @@ -67,9 +68,7 @@ export class UmbStylesheetFolderServerDataSource implements UmbFolderDataSource const parentPath = new UmbServerPathUniqueSerializer().toServerPath(args.parentUnique); const requestBody: CreateStylesheetFolderRequestModel = { - parent: { - path: parentPath, - }, + parent: parentPath ? { path: parentPath } : null, name: args.name, }; @@ -81,8 +80,9 @@ export class UmbStylesheetFolderServerDataSource implements UmbFolderDataSource ); if (data) { - const newPath = this.#serverPathUniqueSerializer.toUnique(data); - return this.read(newPath); + const newPath = decodeURIComponent(data); + const newPathUnique = this.#serverPathUniqueSerializer.toUnique(newPath); + return this.read(newPathUnique); } return { error }; @@ -98,11 +98,12 @@ export class UmbStylesheetFolderServerDataSource implements UmbFolderDataSource if (!unique) throw new Error('Unique is missing'); const path = this.#serverPathUniqueSerializer.toServerPath(unique); + if (!path) throw new Error('Cannot delete stylesheet folder without a path'); return tryExecuteAndNotify( this.#host, StylesheetResource.deleteStylesheetFolderByPath({ - path, + path: encodeURIComponent(path), }), ); }