diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-entry/block-grid-entry.element.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-entry/block-grid-entry.element.ts index c6e89c5e33f3..1028c16199ac 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-entry/block-grid-entry.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-entry/block-grid-entry.element.ts @@ -428,7 +428,7 @@ export class UmbBlockGridEntryElement extends UmbLitElement implements UmbProper ext.component.classList.add('umb-block-grid__block--view'); ext.component.setAttribute('part', 'component'); } - if (this._exposed) { + if (this._exposed || this._isReadOnly) { return ext.component; } else { return html` @@ -582,6 +582,7 @@ export class UmbBlockGridEntryElement extends UmbLitElement implements UmbProper } #renderEditAction() { + if (this._isReadOnly) return nothing; return html` ${when( this._showContentEdit && this._workspaceEditContentPath, @@ -615,6 +616,7 @@ export class UmbBlockGridEntryElement extends UmbLitElement implements UmbProper } #renderEditSettingsAction() { + if (this._isReadOnly) return nothing; return html` ${this._hasSettings && this._workspaceEditSettingsPath ? html` diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-list/components/block-list-entry/block-list-entry.element.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-list/components/block-list-entry/block-list-entry.element.ts index aa9c382d7333..4427002c20e2 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-list/components/block-list-entry/block-list-entry.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-list/components/block-list-entry/block-list-entry.element.ts @@ -357,7 +357,7 @@ export class UmbBlockListEntryElement extends UmbLitElement implements UmbProper #extensionSlotRenderMethod = (ext: UmbExtensionElementInitializer) => { ext.component?.setAttribute('part', 'component'); - if (this._exposed) { + if (this._exposed || this._isReadOnly) { return ext.component; } else { return html`
@@ -455,6 +455,7 @@ export class UmbBlockListEntryElement extends UmbLitElement implements UmbProper } #renderEditContentAction() { + if (this._isReadOnly) return nothing; return this._showContentEdit && this._workspaceEditContentPath ? html` = { contentKey: undefined!, @@ -226,6 +229,11 @@ export class UmbBlockRteEntryElement extends UmbLitElement implements UmbPropert }, null, ); + this.observe( + this.#context.readOnlyGuard.permitted, + (isReadOnly) => (this._isReadOnly = isReadOnly), + 'umbReadOnlyObserver', + ); } async #observeData() { @@ -301,7 +309,7 @@ export class UmbBlockRteEntryElement extends UmbLitElement implements UmbPropert #extensionSlotRenderMethod = (ext: UmbExtensionElementInitializer) => { ext.component?.setAttribute('part', 'component'); - if (this._exposed) { + if (this._exposed || this._isReadOnly) { return ext.component; } else { return html`
@@ -363,6 +371,7 @@ export class UmbBlockRteEntryElement extends UmbLitElement implements UmbPropert } #renderEditAction() { + if (this._isReadOnly) return nothing; return this._showContentEdit && this._workspaceEditContentPath ? html` this.#context.requestDelete()}> diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-single/components/block-single-entry/block-single-entry.element.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-single/components/block-single-entry/block-single-entry.element.ts index ac2d89716a91..b36a97ca7e47 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-single/components/block-single-entry/block-single-entry.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-single/components/block-single-entry/block-single-entry.element.ts @@ -358,7 +358,7 @@ export class UmbBlockSingleEntryElement extends UmbLitElement implements UmbProp #extensionSlotRenderMethod = (ext: UmbExtensionElementInitializer) => { ext.component?.setAttribute('part', 'component'); - if (this._exposed) { + if (this._exposed || this._isReadOnly) { return ext.component; } else { return html`
@@ -441,6 +441,7 @@ export class UmbBlockSingleEntryElement extends UmbLitElement implements UmbProp } #renderEditContentAction() { + if (this._isReadOnly) return nothing; return this._showContentEdit && this._workspaceEditContentPath ? html` + ${when( diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block/conditions/block-workspace-is-readonly.condition.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block/conditions/block-workspace-is-readonly.condition.ts new file mode 100644 index 000000000000..aa3a301ce56d --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block/conditions/block-workspace-is-readonly.condition.ts @@ -0,0 +1,28 @@ +import { UMB_BLOCK_WORKSPACE_CONTEXT } from '../index.js'; +import type { BlockWorkspaceIsReadOnlyConditionConfig } from './types.js'; +import { UmbConditionBase } from '@umbraco-cms/backoffice/extension-registry'; +import type { UmbConditionControllerArguments, UmbExtensionCondition } from '@umbraco-cms/backoffice/extension-api'; +import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; + +export class UmbBlockWorkspaceIsReadOnlyCondition + extends UmbConditionBase + implements UmbExtensionCondition +{ + constructor(host: UmbControllerHost, args: UmbConditionControllerArguments) { + super(host, args); + + this.consumeContext(UMB_BLOCK_WORKSPACE_CONTEXT, (context) => { + this.observe( + context?.readOnlyGuard.permitted, + (isReadOnly) => { + if (isReadOnly !== undefined) { + this.permitted = isReadOnly === (this.config.match !== undefined ? this.config.match : true); + } + }, + 'observeIsReadOnly', + ); + }); + } +} + +export default UmbBlockWorkspaceIsReadOnlyCondition; diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block/conditions/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block/conditions/manifests.ts index 91d527a37b64..0b8ad55ae7c2 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block/conditions/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block/conditions/manifests.ts @@ -1,6 +1,7 @@ import UmbBlockEntryShowContentEditCondition from './block-entry-show-content-edit.condition.js'; import UmbBlockWorkspaceHasSettingsCondition from './block-workspace-has-settings.condition.js'; import UmbBlockEntryIsExposedCondition from './block-workspace-is-exposed.condition.js'; +import UmbBlockWorkspaceIsReadOnlyCondition from './block-workspace-is-readonly.condition.js'; import type { ManifestCondition } from '@umbraco-cms/backoffice/extension-api'; export const manifests: Array = [ @@ -22,4 +23,10 @@ export const manifests: Array = [ alias: 'Umb.Condition.BlockWorkspaceIsExposed', api: UmbBlockEntryIsExposedCondition, }, + { + type: 'condition', + name: 'Block Workspace Is ReadOnly Condition', + alias: 'Umb.Condition.BlockWorkspaceIsReadOnly', + api: UmbBlockWorkspaceIsReadOnlyCondition, + }, ]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block/conditions/types.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block/conditions/types.ts index 1a60f07dea0e..f5aa1cb64331 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block/conditions/types.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block/conditions/types.ts @@ -14,11 +14,18 @@ export interface BlockEntryIsExposedConditionConfig match?: boolean; } +// eslint-disable-next-line @typescript-eslint/naming-convention +export interface BlockWorkspaceIsReadOnlyConditionConfig + extends UmbConditionConfigBase<'Umb.Condition.BlockWorkspaceIsReadOnly'> { + match?: boolean; +} + declare global { interface UmbExtensionConditionConfigMap { umbBlock: | BlockEntryShowContentEditConditionConfig | BlockWorkspaceHasSettingsConditionConfig - | BlockEntryIsExposedConditionConfig; + | BlockEntryIsExposedConditionConfig + | BlockWorkspaceIsReadOnlyConditionConfig; } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-workspace.context.ts index 0703c58778a4..8352926e46cd 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-workspace.context.ts @@ -212,8 +212,12 @@ export class UmbBlockWorkspaceContext = [ alias: 'Umb.Condition.BlockWorkspaceIsExposed', match: false, }, + { + alias: 'Umb.Condition.BlockWorkspaceIsReadOnly', + match: false, + }, ], }, { @@ -47,6 +51,10 @@ export const manifests: Array = [ { alias: 'Umb.Condition.BlockWorkspaceIsExposed', }, + { + alias: 'Umb.Condition.BlockWorkspaceIsReadOnly', + match: false, + }, ], }, {