From 2cfa3e1510e555ecb29fc9629a932359f07ea0fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Wed, 17 May 2023 20:50:10 +0200 Subject: [PATCH] alias approach --- .../backoffice/components/backoffice-main.element.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/apps/backoffice/components/backoffice-main.element.ts b/src/Umbraco.Web.UI.Client/src/apps/backoffice/components/backoffice-main.element.ts index 9d9ce327b9..02f3a4c1e1 100644 --- a/src/Umbraco.Web.UI.Client/src/apps/backoffice/components/backoffice-main.element.ts +++ b/src/Umbraco.Web.UI.Client/src/apps/backoffice/components/backoffice-main.element.ts @@ -13,7 +13,7 @@ import { createExtensionElementOrFallback } from '@umbraco-cms/backoffice/extens @defineElement('umb-backoffice-main') export class UmbBackofficeMainElement extends UmbLitElement { @state() - private _routes: Array = []; + private _routes: Array = []; @state() private _sections: Array = []; @@ -48,14 +48,15 @@ export class UmbBackofficeMainElement extends UmbLitElement { if (!this._sections) return; // TODO: Refactor this for re-use across the app where the routes are re-generated at any time. + // TODO: remove section-routes that does not exist anymore. this._routes = this._sections.map((section) => { - const path = this._routePrefix + section.meta.pathname; - const existingRoute = this._routes.find((r) => r.path === path); + const existingRoute = this._routes.find((r) => r.alias === section.alias); if (existingRoute) { return existingRoute; } else { return { - path: path, + alias: section.alias, + path: this._routePrefix + section.meta.pathname, component: () => createExtensionElementOrFallback(section, 'umb-section-default'), setup: (component) => { (component as UmbSectionExtensionElement).manifest = section; @@ -66,6 +67,7 @@ export class UmbBackofficeMainElement extends UmbLitElement { if (!this._routes.find((r) => r.path === '**')) { this._routes.push({ + alias: '__redirect', path: '**', redirectTo: this._routePrefix + this._sections?.[0]?.meta.pathname, });