diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/views/edit/conditions/has-properties/constants.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/views/edit/conditions/has-properties/constants.ts new file mode 100644 index 0000000000..a37e6add77 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/views/edit/conditions/has-properties/constants.ts @@ -0,0 +1 @@ +export const UMB_CONTENT_HAS_PROPERTIES_WORKSPACE_CONDITION = 'Umb.Condition.Workspace.ContentHasProperties'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/views/edit/conditions/has-properties/content-has-properties.condition.manifest.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/views/edit/conditions/has-properties/content-has-properties.condition.manifest.ts new file mode 100644 index 0000000000..654bbb853b --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/views/edit/conditions/has-properties/content-has-properties.condition.manifest.ts @@ -0,0 +1,8 @@ +import type { ManifestCondition } from '@umbraco-cms/backoffice/extension-api'; + +export const manifest: ManifestCondition = { + type: 'condition', + name: 'Content has properties Workspace Condition', + alias: 'Umb.Condition.Workspace.ContentHasProperties', + api: () => import('./content-has-properties.condition.js'), +}; diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/views/edit/conditions/has-properties/content-has-properties.condition.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/views/edit/conditions/has-properties/content-has-properties.condition.ts new file mode 100644 index 0000000000..b311e27b91 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/views/edit/conditions/has-properties/content-has-properties.condition.ts @@ -0,0 +1,34 @@ +import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; +import type { + UmbConditionConfigBase, + UmbConditionControllerArguments, + UmbExtensionCondition, +} from '@umbraco-cms/backoffice/extension-api'; +import { UMB_CONTENT_WORKSPACE_CONTEXT } from '../../../../content-workspace.context-token.js'; +import { UmbConditionBase } from '@umbraco-cms/backoffice/extension-registry'; +import type { UmbContentTypeModel } from '@umbraco-cms/backoffice/content-type'; +import { UmbContentTypePropertyStructureHelper } from '@umbraco-cms/backoffice/content-type'; + +export class UmbContentHasPropertiesWorkspaceCondition + extends UmbConditionBase + implements UmbExtensionCondition +{ + #propertyStructureHelper = new UmbContentTypePropertyStructureHelper(this); + + constructor(host: UmbControllerHost, args: UmbConditionControllerArguments) { + super(host, args); + + this.consumeContext(UMB_CONTENT_WORKSPACE_CONTEXT, (context) => { + this.observe( + context.structure.contentTypes, + (contentTypes) => { + const hasProperties = contentTypes.some((contentType) => contentType.properties.length > 0); + this.permitted = hasProperties; + }, + 'contentTypesObserver', + ); + }); + } +} + +export { UmbContentHasPropertiesWorkspaceCondition as api }; diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/views/edit/conditions/has-properties/index.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/views/edit/conditions/has-properties/index.ts new file mode 100644 index 0000000000..4f07201dcf --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/views/edit/conditions/has-properties/index.ts @@ -0,0 +1 @@ +export * from './constants.js';