Bugfix: block culture permissions (#18665)

* always allow copy

* add back readonly check

* render pencil icon if the property is read only

---------

Co-authored-by: Niels Lyngsø <nsl@umbraco.dk>
This commit is contained in:
Mads Rasmussen
2025-03-19 20:42:04 +01:00
committed by GitHub
parent 69b69a5fc1
commit b3b1ce2dcd
5 changed files with 19 additions and 15 deletions

View File

@@ -2,10 +2,7 @@ import { UMB_BLOCK_GRID_PROPERTY_EDITOR_UI_ALIAS } from '../property-editors/con
import { manifests as blockManifests } from './block/manifests.js';
import { manifests as gridBlockManifests } from './grid-block/manifests.js';
import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry';
import {
UMB_PROPERTY_HAS_VALUE_CONDITION_ALIAS,
UMB_WRITABLE_PROPERTY_CONDITION_ALIAS,
} from '@umbraco-cms/backoffice/property';
import { UMB_PROPERTY_HAS_VALUE_CONDITION_ALIAS } from '@umbraco-cms/backoffice/property';
const forPropertyEditorUis = [UMB_BLOCK_GRID_PROPERTY_EDITOR_UI_ALIAS];
@@ -24,9 +21,6 @@ export const manifests: Array<UmbExtensionManifest | UmbExtensionManifestKind> =
name: 'Block Grid Copy To Clipboard Property Action',
forPropertyEditorUis,
conditions: [
{
alias: UMB_WRITABLE_PROPERTY_CONDITION_ALIAS,
},
{
alias: UMB_PROPERTY_HAS_VALUE_CONDITION_ALIAS,
},

View File

@@ -23,9 +23,6 @@ export const manifests: Array<UmbExtensionManifest> = [
name: 'Block List Copy To Clipboard Property Action',
forPropertyEditorUis,
conditions: [
{
alias: UMB_WRITABLE_PROPERTY_CONDITION_ALIAS,
},
{
alias: UMB_PROPERTY_HAS_VALUE_CONDITION_ALIAS,
},

View File

@@ -68,6 +68,7 @@ export class UmbBlockListEntryElement extends UmbLitElement implements UmbProper
@state()
_showContentEdit = false;
@state()
_hasSettings = false;
@@ -426,7 +427,7 @@ export class UmbBlockListEntryElement extends UmbLitElement implements UmbProper
look="secondary"
color=${this._contentInvalid ? 'danger' : ''}
href=${this._workspaceEditContentPath}>
<uui-icon name=${this._exposed === false ? 'icon-add' : 'icon-edit'}></uui-icon>
<uui-icon name=${this._exposed === false && this._isReadOnly === false ? 'icon-add' : 'icon-edit'}></uui-icon>
${this._contentInvalid
? html`<uui-badge attention color="danger" label="Invalid content">!</uui-badge>`
: nothing}

View File

@@ -1,4 +1,5 @@
import type { UmbBlockElementManager } from './block-element-manager.js';
import { UMB_BLOCK_WORKSPACE_CONTEXT } from './block-workspace.context-token.js';
import type { UmbPropertyDatasetContext } from '@umbraco-cms/backoffice/property';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import type { UmbVariantId } from '@umbraco-cms/backoffice/variant';
@@ -23,5 +24,16 @@ export class UmbBlockElementPropertyDatasetContext
this.getName = elementManager.getName;
this.culture = createObservablePart(elementManager.variantId, (v) => v?.culture);
this.segment = createObservablePart(elementManager.variantId, (v) => v?.segment);
this.consumeContext(UMB_BLOCK_WORKSPACE_CONTEXT, (workspace) => {
this.observe(
workspace.readOnlyState.states,
(states) => {
const isReadOnly = states.some((state) => state.variantId.equal(elementManager.getVariantId()));
this._readOnly.setValue(isReadOnly);
},
'umbObserveReadOnlyStates',
);
});
}
}

View File

@@ -44,8 +44,8 @@ export abstract class UmbElementPropertyDatasetContext<
#propertyVariantIdMap = new UmbBasicState<UmbPropertyVariantIdMapType>([]);
private readonly _propertyVariantIdMap = this.#propertyVariantIdMap.asObservable();
#readOnly = new UmbBooleanState(false);
public readOnly = this.#readOnly.asObservable();
protected _readOnly = new UmbBooleanState(false);
public readOnly = this._readOnly.asObservable();
getEntityType(): string {
return this._dataOwner.getEntityType();
@@ -56,7 +56,7 @@ export abstract class UmbElementPropertyDatasetContext<
abstract getName(): string | undefined;
getReadOnly() {
return this.#readOnly.getValue();
return this._readOnly.getValue();
}
constructor(host: UmbControllerHost, dataOwner: DataOwnerType, variantId?: UmbVariantId) {
@@ -73,7 +73,7 @@ export abstract class UmbElementPropertyDatasetContext<
this._dataOwner.readOnlyState.states,
(states) => {
const isReadOnly = states.some((state) => state.variantId.equal(this.#variantId));
this.#readOnly.setValue(isReadOnly);
this._readOnly.setValue(isReadOnly);
},
null,
);