Skip to content
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

Feature: Read-only documents #2156

Merged
merged 68 commits into from
Aug 20, 2024
Merged

Conversation

madsrasmussen
Copy link
Contributor

@madsrasmussen madsrasmussen commented Jul 31, 2024

Description

This feature adds the ability to set a workspace in a read-only state. Each part of the workspace can then behave based on the state.

The PR introduces a couple of parts to enable this feature:

Part 1: State Managers

The "core" of the feature is the new "State Manager" system. A state manager holds an array of state entries. If the array has any entries that state is considered "on".

We introduce a "ReadOnly" state manager that can be used in a workspace context. There is one for "standard" workspaces and one for workspaces with variant data.

Implementation
https:/umbraco/Umbraco.CMS.Backoffice/blob/v14/feature/readonly-properties/src/packages/core/utils/state-manager/state.manager.ts

Part 2: Language Permissions

We want to set a property to read-only if the current user does not have access to edit that language/culture.

The language access permission settings on a user group should be considered a feature owned by the Language package/module even though that part of the permission UI is not extendable yet.

It should therefore be possible for the Language package to determine what to do when a user doesn't have access to a language. This is solved by adding a "Workspace Context" extension that sets the read-only state based on the current user language permissions.

This will allow other packages to follow the same principle if they want to set the workspace read-only state. Ex: The Workflow Package wants to make a document read-only if it is part of a workflow.

Implementation:
https:/umbraco/Umbraco.CMS.Backoffice/blob/v14/feature/readonly-properties/src/packages/language/permissions/language-access.workspace-context.ts

Part 3: Readonly badge on languages

An additional UX improvement in this PR is to show what languages are read-only in the document language picker:

Screenshot:
Screenshot 2024-08-06 at 11 11 21

Part 4: Properties reacting to the read-only state manager

The Property Dataset Context
The Property Dataset checks if the active culture is read-only. and sets the state as observable.

The Property Context
The property context checks if a specific property is read-only depending on whether it's varying or invariant (invariant properties can always be edited).

Part 5: Readonly Property Editor UI's

We want as many property editor UIs to implement a read-only mode to achieve the best UX for read-only properties. We can't expect all UI's to support this mode so we have a fallback overlay.

It is possible to set the supportsReadOnly field as part of the Property Editor UI Manifest if the UI has a read-only mode. If this is not set we will add a fallback overlay that prevents interaction.

Part 6: Writable Property Condition

This PR adds a condition to check if a property is writable (not read-only). It is currently used to filter our property actions that should not be shown for read-only documents.

Implementation:
https:/umbraco/Umbraco.CMS.Backoffice/blob/v14/feature/readonly-properties/src/packages/core/property/conditions/writable-property.condition.ts

Current core Property Editor UI's that support read-only

  • label
  • text
  • textarea
  • number
  • tags

What to test:

  • Limit a user to only have access to certain languages
  • Check that language is marked as read only
  • Check that you can interact with the read-only supported property editor but not update the value
  • Check that you can't interact with the property editors that not support read-only mode

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

@madsrasmussen madsrasmussen marked this pull request as ready for review August 6, 2024 10:56
@madsrasmussen madsrasmussen marked this pull request as draft August 13, 2024 05:23
@madsrasmussen madsrasmussen marked this pull request as ready for review August 19, 2024 07:57
Copy link

sonarcloud bot commented Aug 19, 2024

Copy link
Member

@leekelleher leekelleher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested out, all working great! 🚀

@leekelleher leekelleher merged commit f904019 into main Aug 20, 2024
8 checks passed
@leekelleher leekelleher deleted the v14/feature/readonly-properties branch August 20, 2024 10:46
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.

3 participants