From 7e9ce89115957c4937e92ad951ccb5d2dfac6960 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 3 Apr 2024 17:17:18 +0200 Subject: [PATCH] remove the canPerform condition since it only creates overhead and there is no scenario where it would ever be permitted=false --- .../user/user/conditions/manifests.ts | 2 - .../user-can-perform-actions.condition.ts | 44 ------------------- .../user/user/entity-actions/manifests.ts | 20 --------- 3 files changed, 66 deletions(-) delete mode 100644 src/Umbraco.Web.UI.Client/src/packages/user/user/conditions/user-can-perform-actions.condition.ts diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/user/conditions/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/user/user/conditions/manifests.ts index de7909943d..e085874d5e 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/user/user/conditions/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/user/user/conditions/manifests.ts @@ -3,7 +3,6 @@ import { manifest as userAllowEnableActionManifest } from './user-allow-enable-a import { manifest as userAllowUnlockActionManifest } from './user-allow-unlock-action.condition.js'; import { manifest as userAllowMfaActionManifest } from './user-allow-mfa-action.condition.js'; import { manifest as userAllowDeleteActionManifest } from './user-allow-delete-action.condition.js'; -import { manifest as userCanPerformActionsManifest } from './user-can-perform-actions.condition.js'; export const manifests = [ userAllowDisableActionManifest, @@ -11,5 +10,4 @@ export const manifests = [ userAllowUnlockActionManifest, userAllowMfaActionManifest, userAllowDeleteActionManifest, - userCanPerformActionsManifest, ]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/user/conditions/user-can-perform-actions.condition.ts b/src/Umbraco.Web.UI.Client/src/packages/user/user/conditions/user-can-perform-actions.condition.ts deleted file mode 100644 index 988783c49b..0000000000 --- a/src/Umbraco.Web.UI.Client/src/packages/user/user/conditions/user-can-perform-actions.condition.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { UmbUserActionConditionBase } from './user-allow-action-base.condition.js'; -import type { ManifestCondition } from '@umbraco-cms/backoffice/extension-api'; - -/** - * Condition that checks if the current user is allowed to perform actions on the selected user. - * The logic is generally laid out so that admins can perform actions on any user, while users can only perform actions on other users. - */ -export class UmbUserCanPerformActionsCondition extends UmbUserActionConditionBase { - async _onUserDataChange() { - // Must have selected a user - if (this.userUnique === undefined) { - this.permitted = false; - return; - } - - // If the user is the current user, they can perform actions - if (await this.isCurrentUser()) { - this.permitted = true; - return; - } - - // If the current user is an admin, they can perform actions on any user - if (await this.isCurrentUserAdmin()) { - this.permitted = true; - return; - } - - // Otherwise, the current user can only perform actions on other users - if (this.userAdmin) { - this.permitted = false; - return; - } - - // The current user seems to be able to perform actions on the selected user - this.permitted = true; - } -} - -export const manifest: ManifestCondition = { - type: 'condition', - name: 'User Can Perform Actions Condition', - alias: 'Umb.Condition.User.CanPerformActions', - api: UmbUserCanPerformActionsCondition, -}; diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-actions/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-actions/manifests.ts index 087a863c7d..a8200fddfc 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-actions/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-actions/manifests.ts @@ -19,9 +19,6 @@ const entityActions: Array = [ itemRepositoryAlias: UMB_USER_ITEM_REPOSITORY_ALIAS, }, conditions: [ - { - alias: 'Umb.Condition.User.CanPerformActions', - }, { alias: 'Umb.Condition.User.AllowDeleteAction', }, @@ -40,9 +37,6 @@ const entityActions: Array = [ label: 'Enable', }, conditions: [ - { - alias: 'Umb.Condition.User.CanPerformActions', - }, { alias: 'Umb.Condition.User.AllowEnableAction', }, @@ -61,9 +55,6 @@ const entityActions: Array = [ label: 'Disable', }, conditions: [ - { - alias: 'Umb.Condition.User.CanPerformActions', - }, { alias: 'Umb.Condition.User.AllowDisableAction', }, @@ -81,11 +72,6 @@ const entityActions: Array = [ icon: 'icon-key', label: 'Change Password', }, - conditions: [ - { - alias: 'Umb.Condition.User.CanPerformActions', - }, - ], }, { type: 'entityAction', @@ -100,9 +86,6 @@ const entityActions: Array = [ label: 'Unlock', }, conditions: [ - { - alias: 'Umb.Condition.User.CanPerformActions', - }, { alias: 'Umb.Condition.User.AllowUnlockAction', }, @@ -121,9 +104,6 @@ const entityActions: Array = [ label: 'Configure Two-Factor', }, conditions: [ - { - alias: 'Umb.Condition.User.CanPerformActions', - }, { alias: 'Umb.Condition.User.AllowMfaAction', },