Skip to content

Conversation

@madsrasmussen
Copy link
Contributor

@madsrasmussen madsrasmussen commented Nov 17, 2025

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

  • 2 languages
  • Document (Vary by culture)
    • Text 1 (Vary by culture)
    • Text 2 (Shared)
    • Block List 1 (Vary by culture). With a Block 1 and Block 2.
    • Block List 2 (Shared). With a Block 1 and Block 2.
  • Blocks
    • Block 1 (Vary by culture)
      • Text 1 (vary by culture)
      • Text 2 (shared)
    • Block 2 (shared)
      • Text 1
      • Text 2

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:

  • Document
    • Text 1: writeable
    • Text 2: readonly
    • Block List 1: writeable
    • Block List 2: readonly. can open blocks. Can not create or delete blocks.
  • Blocks
    • Block 1
      • Text 1: writeable
      • Text 2: readonly
    • Block 2
      • Text 1: readonly
      • Text 2: readonly

@madsrasmussen madsrasmussen changed the title Blocks: Enforce "AllowEditInvariantFromNonDefault" in variant blocks Block Workspace: Enforce "AllowEditInvariantFromNonDefault" in variant blocks Nov 17, 2025
@madsrasmussen madsrasmussen changed the title Block Workspace: Enforce "AllowEditInvariantFromNonDefault" in variant blocks Block workspace: Enforce "AllowEditInvariantFromNonDefault" in variant blocks Nov 17, 2025
@madsrasmussen madsrasmussen marked this pull request as ready for review November 18, 2025 11:48
Copilot AI review requested due to automatic review settings November 18, 2025 11:48
@madsrasmussen madsrasmussen changed the title Block workspace: Enforce "AllowEditInvariantFromNonDefault" in variant blocks Block workspace: Enforce "AllowEditInvariantFromNonDefault" in variant blocks (closes #20633) Nov 18, 2025
Copilot finished reviewing on behalf of madsrasmussen November 18, 2025 11:52
Copy link
Contributor

Copilot AI left a 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 UmbAllowEditInvariantFromNonDefaultController that 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.ts that referenced non-existent _readOnly field

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

@madsrasmussen madsrasmussen marked this pull request as draft November 18, 2025 13:17
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.
@madsrasmussen madsrasmussen marked this pull request as ready for review November 19, 2025 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In the new variant grid, variant properties are disabled in all the languages - but the default

2 participants