diff --git a/src/packages/block/block-grid/context/block-grid-entries.context.ts b/src/packages/block/block-grid/context/block-grid-entries.context.ts index d2a900ba00..7b5ad26bfc 100644 --- a/src/packages/block/block-grid/context/block-grid-entries.context.ts +++ b/src/packages/block/block-grid/context/block-grid-entries.context.ts @@ -1,6 +1,10 @@ import type { UmbBlockDataType } from '../../block/index.js'; import { UMB_BLOCK_CATALOGUE_MODAL, UmbBlockEntriesContext } from '../../block/index.js'; -import { UMB_BLOCK_GRID_ENTRY_CONTEXT, type UmbBlockGridWorkspaceData } from '../index.js'; +import { + UMB_BLOCK_GRID_ENTRY_CONTEXT, + UMB_BLOCK_GRID_WORKSPACE_MODAL, + type UmbBlockGridWorkspaceData, +} from '../index.js'; import type { UmbBlockGridLayoutModel, UmbBlockGridTypeAreaType, UmbBlockGridTypeModel } from '../types.js'; import { UMB_BLOCK_GRID_MANAGER_CONTEXT } from './block-grid-manager.context-token.js'; import type { UmbBlockGridScalableContainerContext } from './block-grid-scale-manager/block-grid-scale-manager.controller.js'; @@ -21,6 +25,7 @@ export class UmbBlockGridEntriesContext { // #catalogueModal: UmbModalRouteRegistrationController; + #workspaceModal: UmbModalRouteRegistrationController; #parentEntry?: typeof UMB_BLOCK_GRID_ENTRY_CONTEXT.TYPE; @@ -66,13 +71,13 @@ export class UmbBlockGridEntriesContext setParentUnique(contentUdi: string | null) { this.#parentUnique = contentUdi; // Notice pathFolderName can be removed when we have switched to use a proper GUID/ID/KEY. [NL] - this._workspaceModal.setUniquePathValue('parentUnique', pathFolderName(contentUdi ?? 'null')); + this.#workspaceModal.setUniquePathValue('parentUnique', pathFolderName(contentUdi ?? 'null')); this.#catalogueModal.setUniquePathValue('parentUnique', pathFolderName(contentUdi ?? 'null')); } setAreaKey(areaKey: string | null) { this.#areaKey = areaKey; - this._workspaceModal.setUniquePathValue('areaKey', areaKey ?? 'null'); + this.#workspaceModal.setUniquePathValue('areaKey', areaKey ?? 'null'); this.#catalogueModal.setUniquePathValue('areaKey', areaKey ?? 'null'); this.#gotAreaKey(); } @@ -93,8 +98,6 @@ export class UmbBlockGridEntriesContext constructor(host: UmbControllerHost) { super(host, UMB_BLOCK_GRID_MANAGER_CONTEXT); - this._workspaceModal.addUniquePaths(['parentUnique', 'areaKey']); - this.consumeContext(UMB_BLOCK_GRID_ENTRY_CONTEXT, (blockGridEntry) => { this.#parentEntry = blockGridEntry; this.#gotBlockParentEntry(); // is not used at this point. [NL] @@ -119,6 +122,24 @@ export class UmbBlockGridEntriesContext // TODO: Does it make any sense that this is a state? Check usage and confirm. [NL] this._catalogueRouteBuilderState.setValue(routeBuilder); }); + + this.#workspaceModal = new UmbModalRouteRegistrationController(this, UMB_BLOCK_GRID_WORKSPACE_MODAL) + .addUniquePaths(['propertyAlias', 'variantId', 'parentUnique', 'areaKey']) + .addAdditionalPath('block') + .onSetup(() => { + return { + data: { + entityType: 'block', + preset: {}, + originData: { areaKey: this.#areaKey, parentUnique: this.#parentUnique }, + }, + modal: { size: 'medium' }, + }; + }) + .observeRouteBuilder((routeBuilder) => { + const newPath = routeBuilder({}); + this._workspacePath.setValue(newPath); + }); } protected _gotBlockManager() { @@ -131,6 +152,7 @@ export class UmbBlockGridEntriesContext this._manager.propertyAlias, (alias) => { this.#catalogueModal.setUniquePathValue('propertyAlias', alias ?? 'null'); + this.#workspaceModal.setUniquePathValue('propertyAlias', alias ?? 'null'); }, 'observePropertyAlias', ); @@ -138,9 +160,9 @@ export class UmbBlockGridEntriesContext this.observe( this._manager.variantId, (variantId) => { - if (variantId) { - this.#catalogueModal.setUniquePathValue('variantId', variantId.toString()); - } + // TODO: This might not be the property variant ID, but the content variant ID. Check up on what makes most sense? + this.#catalogueModal.setUniquePathValue('variantId', variantId?.toString()); + this.#workspaceModal.setUniquePathValue('variantId', variantId?.toString()); }, 'observePropertyAlias', ); diff --git a/src/packages/block/block-list/context/block-list-entries.context.ts b/src/packages/block/block-list/context/block-list-entries.context.ts index 0a90eede82..f668e69560 100644 --- a/src/packages/block/block-list/context/block-list-entries.context.ts +++ b/src/packages/block/block-list/context/block-list-entries.context.ts @@ -1,6 +1,6 @@ import type { UmbBlockDataType } from '../../block/index.js'; import { UMB_BLOCK_CATALOGUE_MODAL, UmbBlockEntriesContext } from '../../block/index.js'; -import type { UmbBlockListWorkspaceData } from '../index.js'; +import { UMB_BLOCK_LIST_WORKSPACE_MODAL, type UmbBlockListWorkspaceData } from '../index.js'; import type { UmbBlockListLayoutModel, UmbBlockListTypeModel } from '../types.js'; import { UMB_BLOCK_LIST_MANAGER_CONTEXT } from './block-list-manager.context-token.js'; import { UmbBooleanState } from '@umbraco-cms/backoffice/observable-api'; @@ -15,6 +15,7 @@ export class UmbBlockListEntriesContext extends UmbBlockEntriesContext< > { // #catalogueModal: UmbModalRouteRegistrationController; + #workspaceModal: UmbModalRouteRegistrationController; // We will just say its always allowed for list for now: [NL] public readonly canCreate = new UmbBooleanState(true).asObservable(); @@ -40,6 +41,17 @@ export class UmbBlockListEntriesContext extends UmbBlockEntriesContext< .observeRouteBuilder((routeBuilder) => { this._catalogueRouteBuilderState.setValue(routeBuilder); }); + + this.#workspaceModal = new UmbModalRouteRegistrationController(this, UMB_BLOCK_LIST_WORKSPACE_MODAL) + .addUniquePaths(['propertyAlias', 'variantId']) + .addAdditionalPath('block') + .onSetup(() => { + return { data: { entityType: 'block', preset: {} }, modal: { size: 'medium' } }; + }) + .observeRouteBuilder((routeBuilder) => { + const newPath = routeBuilder({}); + this._workspacePath.setValue(newPath); + }); } protected _gotBlockManager() { @@ -64,6 +76,7 @@ export class UmbBlockListEntriesContext extends UmbBlockEntriesContext< this._manager.propertyAlias, (alias) => { this.#catalogueModal.setUniquePathValue('propertyAlias', alias ?? 'null'); + this.#workspaceModal.setUniquePathValue('propertyAlias', alias ?? 'null'); }, 'observePropertyAlias', ); @@ -71,9 +84,9 @@ export class UmbBlockListEntriesContext extends UmbBlockEntriesContext< this.observe( this._manager.variantId, (variantId) => { - if (variantId) { - this.#catalogueModal.setUniquePathValue('variantId', variantId.toString()); - } + // TODO: This might not be the property variant ID, but the content variant ID. Check up on what makes most sense? + this.#catalogueModal.setUniquePathValue('variantId', variantId?.toString()); + this.#workspaceModal.setUniquePathValue('variantId', variantId?.toString()); }, 'observePropertyAlias', ); diff --git a/src/packages/block/block-rte/context/block-rte-entries.context.ts b/src/packages/block/block-rte/context/block-rte-entries.context.ts index abf91afa1c..d6e425370f 100644 --- a/src/packages/block/block-rte/context/block-rte-entries.context.ts +++ b/src/packages/block/block-rte/context/block-rte-entries.context.ts @@ -1,7 +1,10 @@ import type { UmbBlockDataType } from '../../block/index.js'; import { UMB_BLOCK_CATALOGUE_MODAL, UmbBlockEntriesContext } from '../../block/index.js'; -import type { UmbBlockRteWorkspaceData } from '../index.js'; import type { UmbBlockRteLayoutModel, UmbBlockRteTypeModel } from '../types.js'; +import { + UMB_BLOCK_RTE_WORKSPACE_MODAL, + type UmbBlockRteWorkspaceData, +} from '../workspace/block-rte-workspace.modal-token.js'; import { UMB_BLOCK_RTE_MANAGER_CONTEXT } from './block-rte-manager.context-token.js'; import { UmbBooleanState } from '@umbraco-cms/backoffice/observable-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; @@ -15,6 +18,7 @@ export class UmbBlockRteEntriesContext extends UmbBlockEntriesContext< > { // #catalogueModal: UmbModalRouteRegistrationController; + #workspaceModal: UmbModalRouteRegistrationController; // We will just say its always allowed for RTE for now: [NL] public readonly canCreate = new UmbBooleanState(true).asObservable(); @@ -38,6 +42,17 @@ export class UmbBlockRteEntriesContext extends UmbBlockEntriesContext< .observeRouteBuilder((routeBuilder) => { this._catalogueRouteBuilderState.setValue(routeBuilder); }); + + this.#workspaceModal = new UmbModalRouteRegistrationController(this, UMB_BLOCK_RTE_WORKSPACE_MODAL) + .addUniquePaths(['propertyAlias', 'variantId']) + .addAdditionalPath('block') + .onSetup(() => { + return { data: { entityType: 'block', preset: {} }, modal: { size: 'medium' } }; + }) + .observeRouteBuilder((routeBuilder) => { + const newPath = routeBuilder({}); + this._workspacePath.setValue(newPath); + }); } protected _gotBlockManager() { @@ -62,6 +77,7 @@ export class UmbBlockRteEntriesContext extends UmbBlockEntriesContext< this._manager.propertyAlias, (alias) => { this.#catalogueModal.setUniquePathValue('propertyAlias', alias ?? 'null'); + this.#workspaceModal.setUniquePathValue('propertyAlias', alias ?? 'null'); }, 'observePropertyAlias', ); @@ -69,9 +85,9 @@ export class UmbBlockRteEntriesContext extends UmbBlockEntriesContext< this.observe( this._manager.variantId, (variantId) => { - if (variantId) { - this.#catalogueModal.setUniquePathValue('variantId', variantId.toString()); - } + // TODO: This might not be the property variant ID, but the content variant ID. Check up on what makes most sense? + this.#catalogueModal.setUniquePathValue('variantId', variantId?.toString()); + this.#workspaceModal.setUniquePathValue('variantId', variantId?.toString()); }, 'observePropertyAlias', ); diff --git a/src/packages/block/block-rte/workspace/block-rte-workspace.modal-token.ts b/src/packages/block/block-rte/workspace/block-rte-workspace.modal-token.ts index 739c282515..f93502f052 100644 --- a/src/packages/block/block-rte/workspace/block-rte-workspace.modal-token.ts +++ b/src/packages/block/block-rte/workspace/block-rte-workspace.modal-token.ts @@ -1,16 +1,10 @@ -import type { - UmbBlockLayoutBaseModel, - UmbBlockViewPropsType, - UmbBlockWorkspaceData, -} from '@umbraco-cms/backoffice/block'; -import type { UmbWorkspaceModalData } from '@umbraco-cms/backoffice/modal'; +import type { UmbBlockWorkspaceData } from '@umbraco-cms/backoffice/block'; +import type { UmbWorkspaceModalData, UmbWorkspaceModalValue } from '@umbraco-cms/backoffice/modal'; import { UmbModalToken } from '@umbraco-cms/backoffice/modal'; export interface UmbBlockRteWorkspaceData extends UmbBlockWorkspaceData {} -export type UmbBlockRteWorkspaceValue = Array>; - -export const UMB_BLOCK_RTE_WORKSPACE_MODAL = new UmbModalToken( +export const UMB_BLOCK_RTE_WORKSPACE_MODAL = new UmbModalToken( 'Umb.Modal.Workspace', { modal: { @@ -20,4 +14,4 @@ export const UMB_BLOCK_RTE_WORKSPACE_MODAL = new UmbModalToken, UmbBlockRteWorkspaceValue>; +) as UmbModalToken, UmbWorkspaceModalValue>; diff --git a/src/packages/block/block/context/block-entries.context.ts b/src/packages/block/block/context/block-entries.context.ts index 8f145dcdc8..c16929d7b3 100644 --- a/src/packages/block/block/context/block-entries.context.ts +++ b/src/packages/block/block/context/block-entries.context.ts @@ -1,13 +1,13 @@ import type { UmbBlockDataType, UmbBlockLayoutBaseModel } from '../types.js'; -import { UMB_BLOCK_WORKSPACE_MODAL } from '../workspace/block-workspace.modal-token.js'; -import type { UmbBlockDataObjectModel, UmbBlockManagerContext } from './block-manager.context.js'; +import type { UmbBlockWorkspaceData } from '../workspace/block-workspace.modal-token.js'; import { UMB_BLOCK_ENTRIES_CONTEXT } from './block-entries.context-token.js'; +import type { UmbBlockDataObjectModel, UmbBlockManagerContext } from './block-manager.context.js'; +import { type Observable, UmbArrayState, UmbBasicState, UmbStringState } from '@umbraco-cms/backoffice/observable-api'; +import { UmbContextBase } from '@umbraco-cms/backoffice/class-api'; import type { UmbBlockTypeBaseModel } from '@umbraco-cms/backoffice/block-type'; import type { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; -import { UmbContextBase } from '@umbraco-cms/backoffice/class-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; -import { type Observable, UmbArrayState, UmbBasicState, UmbStringState } from '@umbraco-cms/backoffice/observable-api'; -import { type UmbModalRouteBuilder, UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router'; +import type { UmbModalRouteBuilder } from '@umbraco-cms/backoffice/router'; export abstract class UmbBlockEntriesContext< BlockManagerContextTokenType extends UmbContextToken, @@ -21,13 +21,11 @@ export abstract class UmbBlockEntriesContext< _manager?: BlockManagerContextType; _retrieveManager; - _workspaceModal: UmbModalRouteRegistrationController; - protected _catalogueRouteBuilderState = new UmbBasicState(undefined); readonly catalogueRouteBuilder = this._catalogueRouteBuilderState.asObservable(); - #workspacePath = new UmbStringState(undefined); - workspacePath = this.#workspacePath.asObservable(); + protected _workspacePath = new UmbStringState(undefined); + workspacePath = this._workspacePath.asObservable(); public abstract readonly canCreate: Observable; @@ -42,34 +40,7 @@ export abstract class UmbBlockEntriesContext< this._retrieveManager = this.consumeContext(blockManagerContextToken, (blockGridManager) => { this._manager = blockGridManager; this._gotBlockManager(); - - this.observe( - this._manager.propertyAlias, - (alias) => { - this._workspaceModal.setUniquePathValue('propertyAlias', alias); - }, - 'observePropertyAlias', - ); - this.observe( - this._manager.variantId, - (variantId) => { - // TODO: This might not be the property variant ID, but the content variant ID. Check up on what makes most sense? - this._workspaceModal.setUniquePathValue('variantId', variantId?.toString()); - }, - 'observePropertyVariantId', - ); }).asPromise(); - - this._workspaceModal = new UmbModalRouteRegistrationController(this, UMB_BLOCK_WORKSPACE_MODAL) - .addUniquePaths(['propertyAlias', 'variantId']) - .addAdditionalPath('block') - .onSetup(() => { - return { data: { entityType: 'block', preset: {} }, modal: { size: 'medium' } }; - }) - .observeRouteBuilder((routeBuilder) => { - const newPath = routeBuilder({}); - this.#workspacePath.setValue(newPath); - }); } async getManager() { @@ -100,14 +71,14 @@ export abstract class UmbBlockEntriesContext< public abstract create( contentElementTypeKey: string, layoutEntry?: Omit, - modalData?: typeof UMB_BLOCK_WORKSPACE_MODAL.DATA, + modalData?: UmbBlockWorkspaceData, ): Promise | undefined>; abstract insert( layoutEntry: BlockLayoutType, content: UmbBlockDataType, settings: UmbBlockDataType | undefined, - modalData: typeof UMB_BLOCK_WORKSPACE_MODAL.DATA, + modalData: UmbBlockWorkspaceData, ): Promise; //edit? //editSettings diff --git a/src/packages/block/block/workspace/block-workspace.context.ts b/src/packages/block/block/workspace/block-workspace.context.ts index 5ee750a166..867bfb06d2 100644 --- a/src/packages/block/block/workspace/block-workspace.context.ts +++ b/src/packages/block/block/workspace/block-workspace.context.ts @@ -324,7 +324,7 @@ export class UmbBlockWorkspaceContext