use unique in workspace set up

This commit is contained in:
Mads Rasmussen
2023-12-18 15:55:01 +01:00
parent 20c960ac8e
commit 8b69f50855
2 changed files with 11 additions and 25 deletions

View File

@@ -16,7 +16,7 @@ export class UmbScriptWorkspaceElement extends UmbLitElement {
{
path: 'create/:parentUnique',
component: this.#createElement,
setup: async (_component: PageComponent, info: IRoutingInfo) => {
setup: async (component: PageComponent, info: IRoutingInfo) => {
const parentUnique = info.match.params.parentUnique === 'null' ? null : info.match.params.parentUnique;
this.#workspaceContext.create(parentUnique);

View File

@@ -2,10 +2,9 @@ import { UmbStylesheetWorkspaceContext } from './stylesheet-workspace.context.js
import { UmbStylesheetWorkspaceEditorElement } from './stylesheet-workspace-editor.element.js';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
import type { UmbRoute } from '@umbraco-cms/backoffice/router';
import type { IRoutingInfo, PageComponent, UmbRoute } from '@umbraco-cms/backoffice/router';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import { UmbWorkspaceIsNewRedirectController } from '@umbraco-cms/backoffice/workspace';
import { decodeFilePath } from '@umbraco-cms/backoffice/utils';
@customElement('umb-stylesheet-workspace')
export class UmbStylesheetWorkspaceElement extends UmbLitElement {
@@ -15,13 +14,11 @@ export class UmbStylesheetWorkspaceElement extends UmbLitElement {
@state()
_routes: UmbRoute[] = [
{
path: 'create/:path',
path: 'create/:parentUnique',
component: this.#createElement,
setup: async (_component, info) => {
const path = info.match.params.path === 'null' ? null : info.match.params.path;
const serverPath = path === null ? null : decodeFilePath(path);
await this.#workspaceContext.create(serverPath);
await this.#workspaceContext.setRules([]);
setup: async (component: PageComponent, info: IRoutingInfo) => {
const parentUnique = info.match.params.parentUnique === 'null' ? null : info.match.params.parentUnique;
await this.#workspaceContext.create(parentUnique);
new UmbWorkspaceIsNewRedirectController(
this,
@@ -31,13 +28,11 @@ export class UmbStylesheetWorkspaceElement extends UmbLitElement {
},
},
{
path: 'edit/:path',
path: 'edit/:unique',
component: this.#createElement,
setup: (_component, info) => {
this.removeControllerByAlias('_observeIsNew');
const path = info.match.params.path;
const serverPath = decodeFilePath(path);
this.#workspaceContext.load(serverPath);
setup: (component: PageComponent, info: IRoutingInfo) => {
const unique = info.match.params.unique;
this.#workspaceContext.load(unique);
},
},
];
@@ -46,16 +41,7 @@ export class UmbStylesheetWorkspaceElement extends UmbLitElement {
return html` <umb-router-slot .routes=${this._routes}></umb-router-slot> `;
}
static styles = [
UmbTextStyles,
css`
:host {
display: block;
width: 100%;
height: 100%;
}
`,
];
static styles = [UmbTextStyles, css``];
}
export default UmbStylesheetWorkspaceElement;