Skip to content

Commit 8be2d77

Browse files
Only register the Entity Data Picker when we have some registered Data Sources (#20484)
Add conditional registration for Entity Data Picker Introduces an entry point for the Entity Data Picker property editor that registers its manifests only if picker data sources are present, preventing an unusable UI from appearing by default.
1 parent a6eb2a1 commit 8be2d77

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { manifests as entityDataPickerManifests } from './manifests.js';
2+
import type { UmbEntryPointOnInit } from '@umbraco-cms/backoffice/extension-api';
3+
import type { ManifestPropertyEditorDataSource } from '@umbraco-cms/backoffice/property-editor-data-source';
4+
5+
export const onInit: UmbEntryPointOnInit = (host, extensionRegistry) => {
6+
let initialized = false;
7+
8+
/* We register the Entity Data Picker only if any picker data sources have been registered.
9+
This prevents an unusable Property Editor UI from appearing in the list of Property Editors out of the box.
10+
We can remove this code when data sources become more common. */
11+
extensionRegistry
12+
.byTypeAndFilter<'propertyEditorDataSource', ManifestPropertyEditorDataSource>(
13+
'propertyEditorDataSource',
14+
(manifest) => manifest.dataSourceType === 'picker',
15+
)
16+
.subscribe((pickerPropertyEditorDataSource) => {
17+
if (pickerPropertyEditorDataSource.length > 0 && !initialized) {
18+
extensionRegistry.registerMany(entityDataPickerManifests);
19+
initialized = true;
20+
}
21+
});
22+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1+
import { onInit as entityDataPickerOnInit } from './entity-data-picker/entry-point.js';
2+
import type { UmbEntryPointOnInit } from '@umbraco-cms/backoffice/extension-api';
13
import './checkbox-list/components/index.js';
24
import './content-picker/components/index.js';
5+
6+
export const onInit: UmbEntryPointOnInit = (host, extensionRegistry) => {
7+
// We do not have a package for the Entity Data Picker, so we proxy the init call here
8+
entityDataPickerOnInit(host, extensionRegistry);
9+
};

src/Umbraco.Web.UI.Client/src/packages/property-editors/manifests.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { manifests as textareaManifests } from './textarea/manifests.js';
2525
import { manifests as textBoxManifests } from './text-box/manifests.js';
2626
import { manifests as toggleManifests } from './toggle/manifests.js';
2727
import { manifests as contentPickerManifests } from './content-picker/manifests.js';
28-
import { manifests as entityDataPickerManifests } from './entity-data-picker/manifests.js';
2928

3029
export const manifests: Array<UmbExtensionManifest> = [
3130
...checkboxListManifests,
@@ -46,7 +45,6 @@ export const manifests: Array<UmbExtensionManifest> = [
4645
...textBoxManifests,
4746
...toggleManifests,
4847
...contentPickerManifests,
49-
...entityDataPickerManifests,
5048
acceptedType,
5149
colorEditor,
5250
dimensions,

0 commit comments

Comments
 (0)