diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_layout.svelte index 79e4fecf52..82c8e628de 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_layout.svelte @@ -47,12 +47,14 @@ active={$isActive("./navigation")} on:click={() => $goto("./navigation")} /> - $goto("./layouts")} - /> + {#if $store.layouts?.length} + $goto("./layouts")} + /> + {/if} diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_components/LayoutDropdownMenu.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_components/LayoutDropdownMenu.svelte index e5eb1bedd6..cba68f899d 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_components/LayoutDropdownMenu.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_components/LayoutDropdownMenu.svelte @@ -13,7 +13,7 @@ await store.actions.layouts.delete(layout) notifications.success("Layout deleted successfully") } catch (err) { - notifications.error("Error deleting layout") + notifications.error(err?.message || "Error deleting layout") } } diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_components/LayoutListPanel.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_components/LayoutListPanel.svelte index b481280c28..fd38f08ceb 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_components/LayoutListPanel.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_components/LayoutListPanel.svelte @@ -1,25 +1,29 @@ - -
- {#each $store.layouts as layout (layout._id)} - ($store.selectedLayoutId = layout._id)} - > - - - {/each} -
-
+
+ {#each $store.layouts as layout (layout._id)} + ($store.selectedLayoutId = layout._id)} + > + + + {/each} +
+ + diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/_layout.svelte new file mode 100644 index 0000000000..1333c6afe3 --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/_layout.svelte @@ -0,0 +1,12 @@ + + + diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/index.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/index.svelte index a730949499..09d45f8fde 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/index.svelte @@ -6,8 +6,7 @@ onMount(() => { if ($store.layouts?.length) { $redirect(`./${$store.layouts[0]._id}`) - } else { - $redirect("../") } + // The redirection when no layouts exist is handled by the routify layout }) diff --git a/packages/server/src/api/controllers/layout.js b/packages/server/src/api/controllers/layout.js index a92eec424a..826922a047 100644 --- a/packages/server/src/api/controllers/layout.js +++ b/packages/server/src/api/controllers/layout.js @@ -30,19 +30,15 @@ exports.destroy = async function (ctx) { const layoutId = ctx.params.layoutId, layoutRev = ctx.params.layoutRev - if (Object.values(BASE_LAYOUT_PROP_IDS).includes(layoutId)) { - ctx.throw(400, "Cannot delete a built-in layout") - } else { - const layoutsUsedByScreens = ( - await db.allDocs( - getScreenParams(null, { - include_docs: true, - }) - ) - ).rows.map(element => element.doc.layoutId) - if (layoutsUsedByScreens.includes(layoutId)) { - ctx.throw(400, "Cannot delete a layout that's being used by a screen") - } + const layoutsUsedByScreens = ( + await db.allDocs( + getScreenParams(null, { + include_docs: true, + }) + ) + ).rows.map(element => element.doc.layoutId) + if (layoutsUsedByScreens.includes(layoutId)) { + ctx.throw(400, "Cannot delete a layout that's being used by a screen") } await db.remove(layoutId, layoutRev)