Skip to content

Commit 3ccb10d

Browse files
committed
implement/replace existing unique router paths
1 parent 2c8117c commit 3ccb10d

File tree

6 files changed

+33
-100
lines changed

6 files changed

+33
-100
lines changed

src/Umbraco.Web.UI.Client/src/packages/block/block-grid/context/block-grid-entries.context.ts

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ import {
1616
UmbStringState,
1717
} from '@umbraco-cms/backoffice/observable-api';
1818
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
19-
import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
20-
import { pathFolderName } from '@umbraco-cms/backoffice/utils';
19+
import { UmbModalRouteRegistrationController, UmbRoutePathAddendumContext } from '@umbraco-cms/backoffice/router';
2120
import type { UmbNumberRangeValueType } from '@umbraco-cms/backoffice/models';
22-
import { UMB_CONTENT_PROPERTY_DATASET_CONTEXT } from '@umbraco-cms/backoffice/content';
2321

2422
interface UmbBlockGridAreaTypeInvalidRuleType {
2523
groupKey?: string;
@@ -40,11 +38,7 @@ export class UmbBlockGridEntriesContext
4038
implements UmbBlockGridScalableContainerContext
4139
{
4240
//
43-
#catalogueModal: UmbModalRouteRegistrationController<
44-
typeof UMB_BLOCK_CATALOGUE_MODAL.DATA,
45-
typeof UMB_BLOCK_CATALOGUE_MODAL.VALUE
46-
>;
47-
#workspaceModal;
41+
#pathAddendum = new UmbRoutePathAddendumContext(this);
4842

4943
#parentEntry?: typeof UMB_BLOCK_GRID_ENTRY_CONTEXT.TYPE;
5044

@@ -94,9 +88,6 @@ export class UmbBlockGridEntriesContext
9488

9589
setParentUnique(contentKey: string | null) {
9690
this.#parentUnique = contentKey;
97-
// Notice pathFolderName can be removed when we have switched to use a proper GUID/ID/KEY. [NL]
98-
this.#workspaceModal.setUniquePathValue('parentUnique', pathFolderName(contentKey ?? 'null'));
99-
this.#catalogueModal.setUniquePathValue('parentUnique', pathFolderName(contentKey ?? 'null'));
10091
}
10192

10293
getParentUnique(): string | null | undefined {
@@ -105,8 +96,7 @@ export class UmbBlockGridEntriesContext
10596

10697
setAreaKey(areaKey: string | null) {
10798
this.#areaKey = areaKey;
108-
this.#workspaceModal.setUniquePathValue('areaKey', areaKey ?? 'null');
109-
this.#catalogueModal.setUniquePathValue('areaKey', areaKey ?? 'null');
99+
this.#pathAddendum.setAddendum(areaKey ?? '');
110100
this.#gotAreaKey();
111101

112102
// Idea: If we need to parse down a validation data path to target the specific layout object: [NL]
@@ -153,9 +143,8 @@ export class UmbBlockGridEntriesContext
153143
this.#gotBlockParentEntry(); // is not used at this point. [NL]
154144
});
155145

156-
this.#catalogueModal = new UmbModalRouteRegistrationController(this, UMB_BLOCK_CATALOGUE_MODAL)
157-
.addUniquePaths(['propertyAlias', 'variantId', 'parentUnique', 'areaKey'])
158-
.addAdditionalPath(':view/:index')
146+
new UmbModalRouteRegistrationController(this, UMB_BLOCK_CATALOGUE_MODAL)
147+
.addAdditionalPath('_catalogue/:view/:index')
159148
.onSetup((routingInfo) => {
160149
if (!this._manager) return false;
161150
// Idea: Maybe on setup should be async, so it can retrieve the values when needed? [NL]
@@ -199,8 +188,7 @@ export class UmbBlockGridEntriesContext
199188
this._catalogueRouteBuilderState.setValue(routeBuilder);
200189
});
201190

202-
this.#workspaceModal = new UmbModalRouteRegistrationController(this, UMB_BLOCK_GRID_WORKSPACE_MODAL)
203-
.addUniquePaths(['propertyAlias', 'variantId', 'parentUnique', 'areaKey'])
191+
new UmbModalRouteRegistrationController(this, UMB_BLOCK_GRID_WORKSPACE_MODAL)
204192
.addAdditionalPath('block')
205193
.onSetup(() => {
206194
return {
@@ -221,28 +209,13 @@ export class UmbBlockGridEntriesContext
221209
const newPath = routeBuilder({});
222210
this._workspacePath.setValue(newPath);
223211
});
224-
225-
this.consumeContext(UMB_CONTENT_PROPERTY_DATASET_CONTEXT, (dataset) => {
226-
const variantId = dataset.getVariantId();
227-
this.#catalogueModal.setUniquePathValue('variantId', variantId?.toString());
228-
this.#workspaceModal.setUniquePathValue('variantId', variantId?.toString());
229-
});
230212
}
231213

232214
protected _gotBlockManager() {
233215
if (!this._manager) return;
234216

235217
this.#setupAllowedBlockTypes();
236218
this.#setupRangeLimits();
237-
238-
this.observe(
239-
this._manager.propertyAlias,
240-
(alias) => {
241-
this.#catalogueModal.setUniquePathValue('propertyAlias', alias ?? 'null');
242-
this.#workspaceModal.setUniquePathValue('propertyAlias', alias ?? 'null');
243-
},
244-
'observePropertyAlias',
245-
);
246219
}
247220

248221
#gotAreaKey() {

src/Umbraco.Web.UI.Client/src/packages/block/block-list/context/block-list-entries.context.ts

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { UMB_BLOCK_LIST_MANAGER_CONTEXT } from './block-list-manager.context-tok
77
import { UmbBooleanState } from '@umbraco-cms/backoffice/observable-api';
88
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
99
import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
10-
import { UMB_CONTENT_PROPERTY_DATASET_CONTEXT } from '@umbraco-cms/backoffice/content';
1110

1211
export class UmbBlockListEntriesContext extends UmbBlockEntriesContext<
1312
typeof UMB_BLOCK_LIST_MANAGER_CONTEXT,
@@ -17,21 +16,15 @@ export class UmbBlockListEntriesContext extends UmbBlockEntriesContext<
1716
UmbBlockListWorkspaceOriginData
1817
> {
1918
//
20-
#catalogueModal: UmbModalRouteRegistrationController<
21-
typeof UMB_BLOCK_CATALOGUE_MODAL.DATA,
22-
typeof UMB_BLOCK_CATALOGUE_MODAL.VALUE
23-
>;
24-
#workspaceModal;
2519

2620
// We will just say its always allowed for list for now: [NL]
2721
public readonly canCreate = new UmbBooleanState(true).asObservable();
2822

2923
constructor(host: UmbControllerHost) {
3024
super(host, UMB_BLOCK_LIST_MANAGER_CONTEXT);
3125

32-
this.#catalogueModal = new UmbModalRouteRegistrationController(this, UMB_BLOCK_CATALOGUE_MODAL)
33-
.addUniquePaths(['propertyAlias', 'variantId'])
34-
.addAdditionalPath(':view/:index')
26+
new UmbModalRouteRegistrationController(this, UMB_BLOCK_CATALOGUE_MODAL)
27+
.addAdditionalPath('_catalogue/:view/:index')
3528
.onSetup(async (routingInfo) => {
3629
await this._retrieveManager;
3730
if (!this._manager) return false;
@@ -69,8 +62,7 @@ export class UmbBlockListEntriesContext extends UmbBlockEntriesContext<
6962
this._catalogueRouteBuilderState.setValue(routeBuilder);
7063
});
7164

72-
this.#workspaceModal = new UmbModalRouteRegistrationController(this, UMB_BLOCK_LIST_WORKSPACE_MODAL)
73-
.addUniquePaths(['propertyAlias', 'variantId'])
65+
new UmbModalRouteRegistrationController(this, UMB_BLOCK_LIST_WORKSPACE_MODAL)
7466
.addAdditionalPath('block')
7567
.onSetup(() => {
7668
return {
@@ -82,13 +74,6 @@ export class UmbBlockListEntriesContext extends UmbBlockEntriesContext<
8274
const newPath = routeBuilder({});
8375
this._workspacePath.setValue(newPath);
8476
});
85-
86-
// TODO: This must later be switched out with a smarter Modal Registration System, cause here is a issue with Block Editors in inline mode in Block Editors, cause the hosting Block is also of type Content. [NL]
87-
this.consumeContext(UMB_CONTENT_PROPERTY_DATASET_CONTEXT, (dataset) => {
88-
const variantId = dataset.getVariantId();
89-
this.#catalogueModal.setUniquePathValue('variantId', variantId?.toString());
90-
this.#workspaceModal.setUniquePathValue('variantId', variantId?.toString());
91-
});
9277
}
9378

9479
protected _gotBlockManager() {
@@ -108,15 +93,6 @@ export class UmbBlockListEntriesContext extends UmbBlockEntriesContext<
10893
},
10994
'observeThisLayouts',
11095
);
111-
112-
this.observe(
113-
this._manager.propertyAlias,
114-
(alias) => {
115-
this.#catalogueModal.setUniquePathValue('propertyAlias', alias ?? 'null');
116-
this.#workspaceModal.setUniquePathValue('propertyAlias', alias ?? 'null');
117-
},
118-
'observePropertyAlias',
119-
);
12096
}
12197

12298
getPathForCreateBlock(index: number) {

src/Umbraco.Web.UI.Client/src/packages/block/block-rte/context/block-rte-entries.context.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { UMB_BLOCK_RTE_MANAGER_CONTEXT } from './block-rte-manager.context-token
99
import { UmbBooleanState } from '@umbraco-cms/backoffice/observable-api';
1010
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
1111
import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
12-
import { UMB_CONTENT_PROPERTY_DATASET_CONTEXT } from '@umbraco-cms/backoffice/content';
1312

1413
export class UmbBlockRteEntriesContext extends UmbBlockEntriesContext<
1514
typeof UMB_BLOCK_RTE_MANAGER_CONTEXT,
@@ -19,21 +18,15 @@ export class UmbBlockRteEntriesContext extends UmbBlockEntriesContext<
1918
UmbBlockRteWorkspaceOriginData
2019
> {
2120
//
22-
readonly #catalogueModal: UmbModalRouteRegistrationController<
23-
typeof UMB_BLOCK_CATALOGUE_MODAL.DATA,
24-
typeof UMB_BLOCK_CATALOGUE_MODAL.VALUE
25-
>;
26-
readonly #workspaceModal;
2721

2822
// We will just say its always allowed for RTE for now: [NL]
2923
public readonly canCreate = new UmbBooleanState(true).asObservable();
3024

3125
constructor(host: UmbControllerHost) {
3226
super(host, UMB_BLOCK_RTE_MANAGER_CONTEXT);
3327

34-
this.#catalogueModal = new UmbModalRouteRegistrationController(this, UMB_BLOCK_CATALOGUE_MODAL)
35-
.addUniquePaths(['propertyAlias', 'variantId'])
36-
.addAdditionalPath(':view')
28+
new UmbModalRouteRegistrationController(this, UMB_BLOCK_CATALOGUE_MODAL)
29+
.addAdditionalPath('_catalogue/:view')
3730
.onSetup((routingInfo) => {
3831
return {
3932
data: {
@@ -68,8 +61,7 @@ export class UmbBlockRteEntriesContext extends UmbBlockEntriesContext<
6861
this._catalogueRouteBuilderState.setValue(routeBuilder);
6962
});
7063

71-
this.#workspaceModal = new UmbModalRouteRegistrationController(this, UMB_BLOCK_RTE_WORKSPACE_MODAL)
72-
.addUniquePaths(['propertyAlias', 'variantId'])
64+
new UmbModalRouteRegistrationController(this, UMB_BLOCK_RTE_WORKSPACE_MODAL)
7365
.addAdditionalPath('block')
7466
.onSetup(() => {
7567
return { data: { entityType: 'block', preset: {}, baseDataPath: this._dataPath }, modal: { size: 'medium' } };
@@ -78,12 +70,6 @@ export class UmbBlockRteEntriesContext extends UmbBlockEntriesContext<
7870
const newPath = routeBuilder({});
7971
this._workspacePath.setValue(newPath);
8072
});
81-
82-
this.consumeContext(UMB_CONTENT_PROPERTY_DATASET_CONTEXT, (dataset) => {
83-
const variantId = dataset.getVariantId();
84-
this.#catalogueModal.setUniquePathValue('variantId', variantId?.toString());
85-
this.#workspaceModal.setUniquePathValue('variantId', variantId?.toString());
86-
});
8773
}
8874

8975
protected _gotBlockManager() {
@@ -103,15 +89,6 @@ export class UmbBlockRteEntriesContext extends UmbBlockEntriesContext<
10389
},
10490
'observeThisLayouts',
10591
);
106-
107-
this.observe(
108-
this._manager.propertyAlias,
109-
(alias) => {
110-
this.#catalogueModal.setUniquePathValue('propertyAlias', alias ?? 'null');
111-
this.#workspaceModal.setUniquePathValue('propertyAlias', alias ?? 'null');
112-
},
113-
'observePropertyAlias',
114-
);
11592
}
11693

11794
getPathForCreateBlock() {

src/Umbraco.Web.UI.Client/src/packages/block/block-type/components/input-block-type/input-block-type.element.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export class UmbInputBlockTypeElement<
3939
this.dispatchEvent(new CustomEvent('change', { detail: { moveComplete: true } }));
4040
},
4141
});
42-
#elementPickerModal;
4342

4443
@property({ type: Array, attribute: false })
4544
public set value(items) {
@@ -50,9 +49,10 @@ export class UmbInputBlockTypeElement<
5049
return this._items;
5150
}
5251

52+
/** @deprecated will be removed in v17 */
5353
@property({ type: String })
5454
public set propertyAlias(value: string | undefined) {
55-
this.#elementPickerModal.setUniquePathValue('propertyAlias', value);
55+
//this.#elementPickerModal.setUniquePathValue('propertyAlias', value);
5656
}
5757
public get propertyAlias(): string | undefined {
5858
return undefined;
@@ -75,13 +75,16 @@ export class UmbInputBlockTypeElement<
7575
super();
7676
this.consumeContext(UMB_PROPERTY_DATASET_CONTEXT, async (instance) => {
7777
this.#datasetContext = instance;
78-
this.observe(await this.#datasetContext?.propertyValueByAlias('blocks'), (value) => {
79-
this.#filter = value as Array<UmbBlockTypeBaseModel>;
80-
});
78+
this.observe(
79+
await this.#datasetContext?.propertyValueByAlias('blocks'),
80+
(value) => {
81+
this.#filter = value as Array<UmbBlockTypeBaseModel>;
82+
},
83+
'observeBlocks',
84+
);
8185
});
8286

83-
this.#elementPickerModal = new UmbModalRouteRegistrationController(this, UMB_DOCUMENT_TYPE_PICKER_MODAL)
84-
.addUniquePaths(['propertyAlias'])
87+
new UmbModalRouteRegistrationController(this, UMB_DOCUMENT_TYPE_PICKER_MODAL)
8588
.onSetup(() => {
8689
return {
8790
data: {

src/Umbraco.Web.UI.Client/src/packages/block/block/context/block-entry.context.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import type { Observable } from '@umbraco-cms/backoffice/external/rxjs';
2424
import type { UmbBlockTypeBaseModel } from '@umbraco-cms/backoffice/block-type';
2525
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
2626
import { UmbUfmVirtualRenderController } from '@umbraco-cms/backoffice/ufm';
27+
import { UmbRoutePathAddendumContext } from '@umbraco-cms/backoffice/router';
2728

2829
export abstract class UmbBlockEntryContext<
2930
BlockManagerContextTokenType extends UmbContextToken<BlockManagerContextType>,
@@ -45,6 +46,8 @@ export abstract class UmbBlockEntryContext<
4546
_entries?: BlockEntriesContextType;
4647

4748
#contentKey?: string;
49+
50+
#pathAddendum = new UmbRoutePathAddendumContext(this);
4851
#variantId = new UmbClassState<UmbVariantId | undefined>(undefined);
4952
protected readonly _variantId = this.#variantId.asObservable();
5053

@@ -275,6 +278,7 @@ export abstract class UmbBlockEntryContext<
275278
this.observe(
276279
this.unique,
277280
(contentKey) => {
281+
this.#pathAddendum.setAddendum(contentKey);
278282
if (!contentKey) return;
279283
this.#observeContentData();
280284
},

src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-rich-media/input-rich-media.element.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,21 @@ export class UmbInputRichMediaElement extends UUIFormControlMixin(UmbLitElement,
133133
#focalPointEnabled: boolean = false;
134134

135135
@property()
136+
/** @deprecated will be removed in v17 */
136137
public set alias(value: string | undefined) {
137-
this.#modalRouter.setUniquePathValue('propertyAlias', value);
138+
//this.#modalRouter.setUniquePathValue('propertyAlias', value);
138139
}
139140
public get alias(): string | undefined {
140-
return this.#modalRouter.getUniquePathValue('propertyAlias');
141+
return undefined; //this.#modalRouter.getUniquePathValue('propertyAlias');
141142
}
142143

143144
@property()
145+
/** @deprecated will be removed in v17 */
144146
public set variantId(value: string | UmbVariantId | undefined) {
145-
this.#modalRouter.setUniquePathValue('variantId', value?.toString());
147+
//this.#modalRouter.setUniquePathValue('variantId', value?.toString());
146148
}
147149
public get variantId(): string | undefined {
148-
return this.#modalRouter.getUniquePathValue('variantId');
150+
return undefined; //this.#modalRouter.getUniquePathValue('variantId');
149151
}
150152

151153
/**
@@ -177,7 +179,6 @@ export class UmbInputRichMediaElement extends UUIFormControlMixin(UmbLitElement,
177179

178180
#itemRepository = new UmbMediaItemRepository(this);
179181

180-
#modalRouter;
181182
#modalManager?: UmbModalManagerContext;
182183

183184
constructor() {
@@ -187,9 +188,8 @@ export class UmbInputRichMediaElement extends UUIFormControlMixin(UmbLitElement,
187188
this.#modalManager = instance;
188189
});
189190

190-
this.#modalRouter = new UmbModalRouteRegistrationController(this, UMB_IMAGE_CROPPER_EDITOR_MODAL)
191+
new UmbModalRouteRegistrationController(this, UMB_IMAGE_CROPPER_EDITOR_MODAL)
191192
.addAdditionalPath(':key')
192-
.addUniquePaths(['propertyAlias', 'variantId'])
193193
.onSetup((params) => {
194194
const key = params.key;
195195
if (!key) return false;

0 commit comments

Comments
 (0)