Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Conversation

@madsrasmussen
Copy link
Contributor

@madsrasmussen madsrasmussen commented Apr 6, 2024

Description

Implementation of the Document user permissions.

Using the condition in a manifest:

conditions: [
  {
    alias: 'Umb.Condition.UserPermission.Document',
    allOf: [UMB_USER_PERMISSION_DOCUMENT_CREATE],
  },
],

When using a condition on a manifest it will remove the element from the DOM if the conditions aren't met. For workspace actions, we want to disable the button instead. I have solved this by using the condition programmatically in the action class and setting the disable state based on the condition state. It looks something like this:

const condition = new UmbDocumentUserPermissionCondition(host, {
  host,
  config: {
    alias: 'Umb.Condition.UserPermission.Document',
    allOf: [UMB_USER_PERMISSION_DOCUMENT_UPDATE, UMB_USER_PERMISSION_DOCUMENT_PUBLISH],
  },
  onChange: () => {
    condition.permitted ? this.enable() : this.disable();
  },
});

See full example here: https://github.com/umbraco/Umbraco.CMS.Backoffice/pull/1554/files#diff-1ed58ab655d2a26796804f499d7eb7c1ee496c486763fdc16f67a660411852f0R11

How to test?

  • Set up different permission rules for user groups. Both the fallback (default) permissions and granular permissions
  • Make sure that the user can only do what is allowed.

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)

Base automatically changed from feature/entity-context to main April 9, 2024 10:07
@madsrasmussen madsrasmussen marked this pull request as ready for review April 10, 2024 09:38
@leekelleher leekelleher self-requested a review April 10, 2024 10:40
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, works as expected. 👍

@leekelleher leekelleher enabled auto-merge April 10, 2024 13:40
@leekelleher leekelleher merged commit 3604eed into main Apr 10, 2024
@leekelleher leekelleher deleted the feature/document-user-permission branch April 10, 2024 13:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants