Skip to content

Commit 12764fa

Browse files
authored
Merge pull request #2065 from umbraco/v14/feature/block-custom-views
Feature: Block Custom Views
2 parents 268d57a + 4d1bcc9 commit 12764fa

File tree

34 files changed

+574
-252
lines changed

34 files changed

+574
-252
lines changed

src/libs/extension-api/controller/base-extensions-initializer.controller.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export abstract class UmbBaseExtensionsInitializer<
3333
#onChange?: (permittedManifests: Array<MyPermittedControllerType>) => void;
3434
protected _extensions: Array<ControllerType> = [];
3535
#permittedExts: Array<MyPermittedControllerType> = [];
36-
#exposedPermittedExts: Array<MyPermittedControllerType> = [];
36+
#exposedPermittedExts?: Array<MyPermittedControllerType>;
3737
#changeDebounce?: number;
3838

3939
asPromise(): Promise<void> {
@@ -90,6 +90,12 @@ export abstract class UmbBaseExtensionsInitializer<
9090
return;
9191
}
9292

93+
// If we get no manifests and we have not exposed any extensions yet, then we should notify to let the listener know that we have our first response. [NL]
94+
if (manifests.length === 0 && this.#exposedPermittedExts === undefined) {
95+
this.#exposedPermittedExts = [];
96+
this.#onChange?.(this.#exposedPermittedExts);
97+
}
98+
9399
// Clean up extensions that are no longer.
94100
this._extensions = this._extensions.filter((extension) => {
95101
if (!manifests.find((manifest) => manifest.alias === extension.alias)) {
@@ -114,6 +120,7 @@ export abstract class UmbBaseExtensionsInitializer<
114120

115121
protected _extensionChanged = (isPermitted: boolean, controller: ControllerType) => {
116122
let hasChanged = false;
123+
117124
// This might be called after this is destroyed, so we need to check if the _permittedExts is still available:
118125
const existingIndex = this.#permittedExts?.indexOf(controller as unknown as MyPermittedControllerType);
119126
if (isPermitted) {
@@ -149,7 +156,7 @@ export abstract class UmbBaseExtensionsInitializer<
149156
// if so, look up the extension it overwrites, and remove it from the list. and check that for if it overwrites another extension and so on.
150157
if (extCtrl.overwrites.length > 0) {
151158
extCtrl.overwrites.forEach((overwrite) => {
152-
this.#removeOverwrittenExtensions(this.#exposedPermittedExts, overwrite);
159+
this.#removeOverwrittenExtensions(this.#exposedPermittedExts!, overwrite);
153160
});
154161
}
155162
});
@@ -193,16 +200,16 @@ export abstract class UmbBaseExtensionsInitializer<
193200
// The this.#extensionRegistry is an indication of wether this is already destroyed.
194201
if (!this.#extensionRegistry) return;
195202

196-
const oldPermittedExtsLength = this.#exposedPermittedExts.length;
203+
const oldPermittedExtsLength = this.#exposedPermittedExts?.length ?? 0;
197204
(this._extensions as any) = undefined;
198205
(this.#permittedExts as any) = undefined;
199-
this.#exposedPermittedExts.length = 0;
206+
this.#exposedPermittedExts = undefined;
200207
if (this.#changeDebounce) {
201208
cancelAnimationFrame(this.#changeDebounce);
202209
this.#changeDebounce = undefined;
203210
}
204211
if (oldPermittedExtsLength > 0) {
205-
this.#onChange?.(this.#exposedPermittedExts);
212+
this.#onChange?.([]);
206213
}
207214
this.#promiseResolvers.length = 0;
208215
this.#filter = undefined;

src/packages/block/block-grid/components/block-grid-block-inline/block-grid-block-inline.element.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { UmbBlockGridInlinePropertyDatasetContext } from './block-grid-inline-pr
33
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
44
import { css, customElement, html, property, state } from '@umbraco-cms/backoffice/external/lit';
55
import type { UmbPropertyTypeModel } from '@umbraco-cms/backoffice/content-type';
6-
import type { UmbBlockViewUrlsPropType } from '@umbraco-cms/backoffice/block';
6+
import type { UmbBlockEditorCustomViewConfiguration } from '@umbraco-cms/backoffice/extension-registry';
77
import '../block-grid-areas-container/index.js';
88
import '../ref-grid-block/index.js';
99

@@ -17,7 +17,7 @@ export class UmbBlockGridBlockInlineElement extends UmbLitElement {
1717
label?: string;
1818

1919
@property({ attribute: false })
20-
urls?: UmbBlockViewUrlsPropType;
20+
config?: UmbBlockEditorCustomViewConfiguration;
2121

2222
@state()
2323
_inlineProperty: UmbPropertyTypeModel | undefined;
@@ -39,7 +39,7 @@ export class UmbBlockGridBlockInlineElement extends UmbLitElement {
3939
}
4040

4141
override render() {
42-
return html`<umb-ref-grid-block standalone .name=${this.label ?? ''} href=${this.urls?.editContent ?? ''}>
42+
return html`<umb-ref-grid-block standalone .name=${this.label ?? ''} href=${this.config?.editContentPath ?? ''}>
4343
<umb-property-type-based-property
4444
.property=${this._inlineProperty}
4545
slot="areas"></umb-property-type-based-property>

src/packages/block/block-grid/components/block-grid-block/block-grid-block.element.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { UMB_BLOCK_GRID_ENTRY_CONTEXT } from '../../context/block-grid-entry.context-token.js';
22
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
33
import { css, customElement, html, property, state } from '@umbraco-cms/backoffice/external/lit';
4-
import type { UmbBlockDataType, UmbBlockViewUrlsPropType } from '@umbraco-cms/backoffice/block';
4+
import type { UmbBlockEditorCustomViewConfiguration } from '@umbraco-cms/backoffice/extension-registry';
5+
import type { UmbBlockDataType } from '@umbraco-cms/backoffice/block';
56

67
import '@umbraco-cms/backoffice/ufm';
78
import '../block-grid-areas-container/index.js';
@@ -17,7 +18,7 @@ export class UmbBlockGridBlockElement extends UmbLitElement {
1718
label?: string;
1819

1920
@property({ attribute: false })
20-
urls?: UmbBlockViewUrlsPropType;
21+
config?: UmbBlockEditorCustomViewConfiguration;
2122

2223
@state()
2324
_content?: UmbBlockDataType;
@@ -37,7 +38,7 @@ export class UmbBlockGridBlockElement extends UmbLitElement {
3738
}
3839

3940
override render() {
40-
return html`<umb-ref-grid-block standalone href=${this.urls?.editContent ?? ''}>
41+
return html`<umb-ref-grid-block standalone href=${this.config?.editContentPath ?? ''}>
4142
<umb-ufm-render inline .markdown=${this.label} .value=${this._content}></umb-ufm-render>
4243
<umb-block-grid-areas-container slot="areas"></umb-block-grid-areas-container>
4344
</umb-ref-grid-block>`;

0 commit comments

Comments
 (0)