-
Notifications
You must be signed in to change notification settings - Fork 2.8k
User group: permissions grouping #20584
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
Merged
madsrasmussen
merged 9 commits into
release/17.0
from
v17/hotfix/user-group-permissions-grouping
Oct 21, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1faebe3
clean up
nielslyngsoe 0e4662d
Merge branch 'release/17.0' into v17/hotfix/user-group-permissions-gr…
nielslyngsoe 80e4dc9
localizations
nielslyngsoe b1c02f6
group user permission by entity type
nielslyngsoe 9f35db8
adjustments
nielslyngsoe a4e55cc
fix lint errors
madsrasmussen 7a62a1f
Merge branch 'release/17.0' into v17/hotfix/user-group-permissions-gr…
iOvergaard 9cc9d1d
Support granular permissions without entity type
madsrasmussen 83091a3
revert for now
madsrasmussen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/Umbraco.Web.UI.Client/examples/user-permission/localization/en.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| export default { | ||
| user: { | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| permissionsEntityGroup_dictionary: 'Dictionary', | ||
| permissionsEntityGroup_dictionary: 'Dictionary permissions', | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...group/workspace/user-group/components/user-group-entity-type-permission-groups.element.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; | ||
| import { html, customElement, state, repeat, css, nothing } from '@umbraco-cms/backoffice/external/lit'; | ||
| import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; | ||
| import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry'; | ||
|
|
||
| import './user-group-entity-type-permissions.element.js'; | ||
| import './user-group-entity-type-granular-permissions.element.js'; | ||
|
|
||
| @customElement('umb-user-group-entity-type-permission-groups') | ||
| export class UmbUserGroupEntityTypePermissionGroupsElement extends UmbLitElement { | ||
| @state() | ||
| private _groups: Array<{ entityType: string; headline: string }> = []; | ||
|
|
||
| @state() | ||
| private _hasGranularPermissionsWithNoEntityType = false; | ||
|
|
||
| constructor() { | ||
| super(); | ||
|
|
||
| this.observe( | ||
| umbExtensionsRegistry.byType('entityUserPermission'), | ||
| (manifests) => { | ||
| const entityTypes = [...new Set(manifests.flatMap((manifest) => manifest.forEntityTypes))]; | ||
| this._groups = entityTypes | ||
| .map((entityType) => { | ||
| return { | ||
| entityType, | ||
| headline: this.localize.term(`user_permissionsEntityGroup_${entityType}`), | ||
| }; | ||
| }) | ||
| .sort((a, b) => a.headline.localeCompare(b.headline)); | ||
| }, | ||
| 'umbUserPermissionsObserver', | ||
| ); | ||
|
|
||
| this.#observeGranularPermissionsWithNoEntityType(); | ||
| } | ||
|
|
||
| #observeGranularPermissionsWithNoEntityType() { | ||
| this.observe( | ||
| umbExtensionsRegistry.byTypeAndFilter( | ||
| 'userGranularPermission', | ||
| (manifest) => manifest.forEntityTypes === undefined || manifest.forEntityTypes.length === 0, | ||
| ), | ||
| (manifests) => { | ||
| this._hasGranularPermissionsWithNoEntityType = manifests.length > 0; | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| override render() { | ||
| return html`${repeat( | ||
| this._groups, | ||
| (group) => group.entityType, | ||
| (group) => | ||
| html`<uui-box> | ||
| <div slot="headline">${group.headline}</div> | ||
|
|
||
| <umb-user-group-entity-type-permissions | ||
| .entityType=${group.entityType}></umb-user-group-entity-type-permissions> | ||
|
|
||
| <umb-user-group-entity-type-granular-permissions | ||
| .entityType=${group.entityType}></umb-user-group-entity-type-granular-permissions> | ||
| </uui-box>`, | ||
| )} | ||
| ${this.#renderUngroupedGranularPermissions()}`; | ||
| } | ||
|
|
||
| #renderUngroupedGranularPermissions() { | ||
| if (!this._hasGranularPermissionsWithNoEntityType) return nothing; | ||
| return html`<uui-box headline=${this.localize.term('general_rights')}> | ||
| <umb-user-group-entity-type-granular-permissions></umb-user-group-entity-type-granular-permissions | ||
| ></uui-box>`; | ||
| } | ||
|
|
||
| static override styles = [ | ||
| UmbTextStyles, | ||
| css` | ||
| uui-box { | ||
| margin-top: var(--uui-size-space-6); | ||
| } | ||
| `, | ||
| ]; | ||
| } | ||
|
|
||
| export default UmbUserGroupEntityTypePermissionGroupsElement; | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| 'umb-user-group-entity-type-permission-groups': UmbUserGroupEntityTypePermissionGroupsElement; | ||
| } | ||
| } |
60 changes: 60 additions & 0 deletions
60
.../user-group/workspace/user-group/components/user-group-entity-type-permissions.element.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { UMB_USER_GROUP_WORKSPACE_CONTEXT } from '../user-group-workspace.context-token.js'; | ||
| import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; | ||
| import { html, customElement, state, nothing, property } from '@umbraco-cms/backoffice/external/lit'; | ||
| import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; | ||
| import type { UmbSelectionChangeEvent } from '@umbraco-cms/backoffice/event'; | ||
|
|
||
| @customElement('umb-user-group-entity-type-permissions') | ||
| export class UmbUserGroupEntityTypePermissionsElement extends UmbLitElement { | ||
| @property() | ||
| public entityType?: string; | ||
|
|
||
| @state() | ||
| private _fallBackPermissions?: Array<string>; | ||
|
|
||
| #userGroupWorkspaceContext?: typeof UMB_USER_GROUP_WORKSPACE_CONTEXT.TYPE; | ||
|
|
||
| constructor() { | ||
| super(); | ||
|
|
||
| this.consumeContext(UMB_USER_GROUP_WORKSPACE_CONTEXT, (instance) => { | ||
| this.#userGroupWorkspaceContext = instance; | ||
| this.observe( | ||
| this.#userGroupWorkspaceContext?.fallbackPermissions, | ||
| (fallbackPermissions) => { | ||
| this._fallBackPermissions = fallbackPermissions; | ||
| }, | ||
| 'umbUserGroupEntityUserPermissionsObserver', | ||
| ); | ||
| }); | ||
| } | ||
|
|
||
| #onPermissionChange(event: UmbSelectionChangeEvent) { | ||
| event.stopPropagation(); | ||
| const target = event.target as any; | ||
| const verbs = target.allowedVerbs; | ||
| if (verbs === undefined || verbs === null) throw new Error('The verbs are not defined'); | ||
| this.#userGroupWorkspaceContext?.setFallbackPermissions(verbs); | ||
| } | ||
|
|
||
| override render() { | ||
| return this.entityType | ||
| ? html` | ||
| <umb-input-entity-user-permission | ||
| .entityType=${this.entityType} | ||
| .allowedVerbs=${this._fallBackPermissions || []} | ||
| @change=${this.#onPermissionChange}></umb-input-entity-user-permission> | ||
| ` | ||
| : nothing; | ||
| } | ||
|
|
||
| static override styles = [UmbTextStyles]; | ||
| } | ||
|
|
||
| export default UmbUserGroupEntityTypePermissionsElement; | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| 'umb-user-group-entity-type-permissions': UmbUserGroupEntityTypePermissionsElement; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.