Add workspace view path const (#17880)

* use path const for workspace view

* get base path and active path from router context

---------

Co-authored-by: Kenn Jacobsen <kja@umbraco.dk>
This commit is contained in:
Niels Lyngsø
2025-01-07 19:26:10 +01:00
committed by GitHub
parent 79c8652ca4
commit bf9ba16039
3 changed files with 14 additions and 2 deletions

View File

@@ -37,6 +37,13 @@ export class UmbRouteContext extends UmbContextBase<UmbRouteContext> {
});
}
getBasePath() {
return this.#basePath.getValue();
}
getActivePath() {
return this.getBasePath() + '/' + this.#activeLocalPath;
}
public registerModal(registration: UmbModalRouteRegistration) {
this.#modalRegistrations.push(registration);
this.#createNewUrlBuilder(registration);

View File

@@ -3,7 +3,7 @@ import { createExtensionElement, UmbExtensionsManifestInitializer } from '@umbra
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import type { ManifestWorkspaceView } from '@umbraco-cms/backoffice/workspace';
import { UMB_WORKSPACE_VIEW_PATH_PATTERN, type ManifestWorkspaceView } from '@umbraco-cms/backoffice/workspace';
import type { UmbRoute, UmbRouterSlotInitEvent, UmbRouterSlotChangeEvent } from '@umbraco-cms/backoffice/router';
/**
@@ -62,7 +62,7 @@ export class UmbWorkspaceEditorElement extends UmbLitElement {
if (this._workspaceViews.length > 0) {
newRoutes = this._workspaceViews.map((manifest) => {
return {
path: `view/${manifest.meta.pathname}`,
path: UMB_WORKSPACE_VIEW_PATH_PATTERN.generateLocal({ viewPathname: manifest.meta.pathname }),
component: () => createExtensionElement(manifest),
setup: (component) => {
if (component) {

View File

@@ -5,3 +5,8 @@ export const UMB_WORKSPACE_PATH_PATTERN = new UmbPathPattern<
{ entityType: string },
typeof UMB_SECTION_PATH_PATTERN.ABSOLUTE_PARAMS
>('workspace/:entityType', UMB_SECTION_PATH_PATTERN);
export const UMB_WORKSPACE_VIEW_PATH_PATTERN = new UmbPathPattern<
{ viewPathname: string },
typeof UMB_WORKSPACE_PATH_PATTERN.ABSOLUTE_PARAMS
>('view/:viewPathname', UMB_WORKSPACE_PATH_PATTERN);