diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/entity/entity.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/entity/entity.context.ts index 4770a11be3..f3058608df 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/entity/entity.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/entity/entity.context.ts @@ -1,4 +1,5 @@ import { UMB_ENTITY_CONTEXT } from './entity.context-token.js'; +import type { UmbEntityUnique } from './types.js'; import { UmbContextBase } from '@umbraco-cms/backoffice/class-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { UmbStringState } from '@umbraco-cms/backoffice/observable-api'; @@ -12,7 +13,7 @@ export class UmbEntityContext extends UmbContextBase { #entityType = new UmbStringState(undefined); public readonly entityType = this.#entityType.asObservable(); - #unique = new UmbStringState(undefined); + #unique = new UmbStringState(null); public readonly unique = this.#unique.asObservable(); /** @@ -44,16 +45,16 @@ export class UmbEntityContext extends UmbContextBase { /** * Set the unique - * @param {string | null | undefined} unique + * @param {string | null} unique * @memberof UmbEntityContext */ - setUnique(unique: string | null | undefined) { + setUnique(unique: string | null) { this.#unique.setValue(unique); } /** * Get the unique - * @returns {string | null | undefined} + * @returns {string | null} * @memberof UmbEntityContext */ getUnique() { diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/workspace/kinds/default/default-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/workspace/kinds/default/default-workspace.context.ts index e368fc2196..53c308a1af 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/workspace/kinds/default/default-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/workspace/kinds/default/default-workspace.context.ts @@ -3,17 +3,14 @@ import type { UmbWorkspaceContext } from '../../workspace-context.interface.js'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { UmbContextBase } from '@umbraco-cms/backoffice/class-api'; import type { ManifestWorkspace } from '@umbraco-cms/backoffice/workspace'; -import { UmbEntityContext } from '@umbraco-cms/backoffice/entity'; +import { UmbEntityContext, type UmbEntityUnique } from '@umbraco-cms/backoffice/entity'; -export abstract class UmbDefaultWorkspaceContext +export class UmbDefaultWorkspaceContext extends UmbContextBase implements UmbWorkspaceContext { public workspaceAlias!: string; - #entityType!: string; - #unique: string | null = null; - #entityContext = new UmbEntityContext(this); constructor(host: UmbControllerHost) { @@ -22,18 +19,23 @@ export abstract class UmbDefaultWorkspaceContext set manifest(manifest: ManifestWorkspace) { this.workspaceAlias = manifest.alias; - this.#entityType = manifest.meta.entityType; - - this.#entityContext.setEntityType(this.#entityType); - this.#entityContext.setUnique(this.#unique); + this.setEntityType(manifest.meta.entityType); } - getUnique(): string | null { - return this.#unique; + setUnique(unique: UmbEntityUnique): void { + this.#entityContext.setUnique(unique); + } + + getUnique(): UmbEntityUnique { + return this.#entityContext.getUnique(); + } + + setEntityType(entityType: string): void { + this.#entityContext.setEntityType(entityType); } getEntityType(): string { - return this.#entityType; + return this.#entityContext.getEntityType()!; } }