Skip to content

Commit 3873b5b

Browse files
authored
Merge pull request #17929 from umbraco/v15/bugfix/17312
Fix/Feature: Introducing Route Path Addendum
2 parents aaad9c0 + 533a644 commit 3873b5b

File tree

28 files changed

+300
-123
lines changed

28 files changed

+300
-123
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/core/collection/components/collection-view-bundle.element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { UMB_COLLECTION_CONTEXT } from '../default/index.js';
22
import type { ManifestCollectionView } from '../extensions/types.js';
33
import type { UmbCollectionLayoutConfiguration } from '../types.js';
4-
import { UMB_ROUTE_CONTEXT } from '../../router/route.context.js';
54
import { css, customElement, html, nothing, query, repeat, state } from '@umbraco-cms/backoffice/external/lit';
65
import { observeMultiple } from '@umbraco-cms/backoffice/observable-api';
76
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
87
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
98
import { UMB_ENTITY_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace';
109
import type { UUIPopoverContainerElement } from '@umbraco-cms/backoffice/external/uui';
10+
import { UMB_ROUTE_CONTEXT } from '@umbraco-cms/backoffice/router';
1111

1212
interface UmbCollectionViewLayout {
1313
alias: string;

src/Umbraco.Web.UI.Client/src/packages/core/content/property-dataset-context/content-property-dataset.context.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
55
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
66
import type { UmbEntityVariantModel, UmbVariantId } from '@umbraco-cms/backoffice/variant';
77
import type { UmbContentTypeModel } from '@umbraco-cms/backoffice/content-type';
8+
import { UmbRoutePathAddendumContext } from '@umbraco-cms/backoffice/router';
89

910
export class UmbContentPropertyDatasetContext<
1011
ContentModel extends UmbContentDetailModel = UmbContentDetailModel,
@@ -16,6 +17,7 @@ export class UmbContentPropertyDatasetContext<
1617
UmbContentWorkspaceContext<ContentModel, ContentTypeModel, VariantModelType>
1718
> {
1819
//
20+
#pathAddendum = new UmbRoutePathAddendumContext(this);
1921
#currentVariant = new UmbObjectState<VariantModelType | undefined>(undefined);
2022
currentVariant = this.#currentVariant.asObservable();
2123

@@ -47,6 +49,8 @@ export class UmbContentPropertyDatasetContext<
4749
// The controller alias, is a very generic name cause we want only one of these for this controller host.
4850
super(host, dataOwner, variantId);
4951

52+
this.#pathAddendum.setAddendum(variantId ? variantId.toString() : '');
53+
5054
this.observe(
5155
this._dataOwner.variantById(this.getVariantId()),
5256
async (variantInfo) => {

src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/views/edit/content-editor.element.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export class UmbContentWorkspaceViewEditElement extends UmbLitElement implements
148148
: ''}
149149
150150
<umb-router-slot
151+
inherit-addendum
151152
.routes=${this._routes}
152153
@init=${(event: UmbRouterSlotInitEvent) => {
153154
this._routerPath = event.target.absoluteRouterPath;

src/Umbraco.Web.UI.Client/src/packages/core/modal/context/modal.context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { UmbModalToken } from '../token/modal-token.js';
2-
import { UMB_ROUTE_CONTEXT } from '../../router/route.context.js';
32
import type { UmbModalConfig, UmbModalType } from '../types.js';
43
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
54
import type { IRouterSlot } from '@umbraco-cms/backoffice/external/router-slot';
@@ -9,6 +8,7 @@ import { UmbObjectState, UmbStringState } from '@umbraco-cms/backoffice/observab
98
import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
109
import { type UmbDeepPartialObject, umbDeepMerge } from '@umbraco-cms/backoffice/utils';
1110
import type { ElementLoaderProperty } from '@umbraco-cms/backoffice/extension-api';
11+
import { UMB_ROUTE_CONTEXT } from '@umbraco-cms/backoffice/router';
1212

1313
export interface UmbModalRejectReason {
1414
type: string;

src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.element.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type {
2020
} from '@umbraco-cms/backoffice/content-type';
2121
import type { UmbObserverController } from '@umbraco-cms/backoffice/observable-api';
2222
import { UMB_MARK_ATTRIBUTE_NAME } from '@umbraco-cms/backoffice/const';
23+
import { UmbRoutePathAddendumContext } from '@umbraco-cms/backoffice/router';
2324

2425
/**
2526
* @element umb-property
@@ -171,6 +172,7 @@ export class UmbPropertyElement extends UmbLitElement {
171172
private _isReadOnly = false;
172173

173174
#propertyContext = new UmbPropertyContext(this);
175+
#pathAddendum = new UmbRoutePathAddendumContext(this);
174176

175177
#controlValidator?: UmbFormControlValidator;
176178
#validationMessageBinder?: UmbBindServerValidationToFormControl;
@@ -184,6 +186,7 @@ export class UmbPropertyElement extends UmbLitElement {
184186
this.#propertyContext.alias,
185187
(alias) => {
186188
this._alias = alias;
189+
this.#pathAddendum.setAddendum(alias);
187190
},
188191
null,
189192
);

0 commit comments

Comments
 (0)