diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace.element.ts index d3e6e97923..cd91525a5b 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace.element.ts @@ -36,28 +36,44 @@ export class UmbWorkspaceElement extends UmbLitElement { _routes: Array = []; async #createRoutes(workspaceManifest: ManifestWorkspace) { - const workspaceContextModule = await workspaceManifest.meta.api(); - const workspaceContext = new workspaceContextModule.default(this); - const paths = await workspaceContext.getPaths(); + const workspaceContextModule = await workspaceManifest.meta.api?.(); + const workspaceContext = workspaceContextModule ? new workspaceContextModule.default(this) : undefined; + const paths = (await workspaceContext?.getPaths?.()) || []; const routes = paths.map((path: any) => { return { path: path.path, component: () => createExtensionElement(workspaceManifest), - setup: (component: Promise, info: IRoutingInfo) => { - component.then((element) => { - element.manifest = workspaceManifest; - const location: UmbRouteLocation = { - name: path.name, - params: info.match.params, - }; - element.location = location; - }); - }, + setup: (component: Promise, info: IRoutingInfo) => + this.#onRouteSetup(component, info, path, workspaceManifest), }; }); - this._routes = routes; + this._routes = [ + ...routes, + { + path: '**', + component: () => createExtensionElement(workspaceManifest), + setup: (component: Promise, info: IRoutingInfo) => + this.#onRouteSetup(component, info, { name: 'catch-all', params: {} }, workspaceManifest), + }, + ]; + } + + #onRouteSetup( + component: Promise, + info: IRoutingInfo, + path: any, + workspaceManifest: ManifestWorkspace + ) { + component.then((element) => { + element.manifest = workspaceManifest; + const location: UmbRouteLocation = { + name: path.name, + params: info.match.params, + }; + element.location = location; + }); } #observeWorkspace() {