-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Block workspace: Enforce "AllowEditInvariantFromNonDefault" in variant blocks (closes #20633) #20868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Block workspace: Enforce "AllowEditInvariantFromNonDefault" in variant blocks (closes #20633) #20868
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements enforcement of the AllowEditInvariantFromNonDefault configuration for variant blocks by extracting the configuration logic into a dedicated controller that works with both Document and Block workspaces. This achieves better separation of concerns by moving the configuration enforcement out of the workspace context classes.
- Created a new
UmbAllowEditInvariantFromNonDefaultControllerthat handles the configuration enforcement for both Document and Block workspaces - Registered the controller as a workspace context for both Document and Block workspace aliases
- Removed dead code from
block-element-property-dataset.context.tsthat referenced non-existent_readOnlyfield
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Umbraco.Web.UI.Client/src/packages/documents/documents/manifests.ts | Registers the new allow-edit-invariant-from-non-default manifests in the document package |
| src/Umbraco.Web.UI.Client/src/packages/documents/documents/allow-edit-invariant-from-non-default/manifests.ts | Defines workspace context manifests for both Document and Block workspaces to enforce the configuration |
| src/Umbraco.Web.UI.Client/src/packages/documents/documents/allow-edit-invariant-from-non-default/allow-edit-invariant-from-non-default.controller.ts | Implements the controller that prevents editing invariant properties from non-default language variants based on configuration |
| src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-property-dataset.context.ts | Removes unused read-only guard observation code that referenced non-existent _readOnly field |
| src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/block-element-manager.ts | Removes extraneous blank line for code cleanliness |
...ts/allow-edit-invariant-from-non-default/allow-edit-invariant-from-non-default.controller.ts
Outdated
Show resolved
Hide resolved
...ts/allow-edit-invariant-from-non-default/allow-edit-invariant-from-non-default.controller.ts
Outdated
Show resolved
Hide resolved
...I.Client/src/packages/documents/documents/allow-edit-invariant-from-non-default/manifests.ts
Show resolved
Hide resolved
…efault-in-variant-blocks
Extracted the creation of the invariant property edit guard rule into a reusable _createRule method in the controller base class. Updated block and document workspace controllers to use this method
Moved the logic for observing properties and variant options and applying property guard rules into a new _observeAndApplyRule method in the base controller. Updated document block and workspace controllers to use this shared method, reducing code duplication and improving maintainability.
Extracted logic for checking invariant blocks and default language datasets into private async methods for better readability and maintainability. This refactor also corrects a context check typo and improves error handling.
Fixes #20633
This PR implements the configuration for “AllowEditInvariantFromNonDefault” for variant blocks.
To achieve a clear separation between the configuration and the Document/Block implementation, I have moved the configuration enforcement into its own controller and registered it as a workspace context for the Document and Block workspaces.
Test cases of AllowEditInvariantFromNonDefault:
Setup
Case: True
From default language: All properties are always writable
From non-default language: All properties are always writable
Case False
Result:
From default language: All properties are always writable
From non-default language: