From 1b3309384e107beef6be6fe96df4de30c5db824e Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Tue, 5 Mar 2024 14:39:48 +0100 Subject: [PATCH] SONAR-21642 Fix project permissions for project admin --- .../js/components/permissions/GroupHolder.tsx | 38 ++++++------------- .../js/components/permissions/HoldersList.tsx | 2 - .../js/components/permissions/UserHolder.tsx | 29 ++++++-------- 3 files changed, 23 insertions(+), 46 deletions(-) diff --git a/server/sonar-web/src/main/js/components/permissions/GroupHolder.tsx b/server/sonar-web/src/main/js/components/permissions/GroupHolder.tsx index f1a56da82f1..d2a1a874c6a 100644 --- a/server/sonar-web/src/main/js/components/permissions/GroupHolder.tsx +++ b/server/sonar-web/src/main/js/components/permissions/GroupHolder.tsx @@ -22,9 +22,8 @@ import * as React from 'react'; import { translate } from '../../helpers/l10n'; import { isPermissionDefinitionGroup } from '../../helpers/permissions'; import { getBaseUrl } from '../../helpers/system'; -import { useIdentityProviderQuery } from '../../queries/identity-provider/common'; import { Permissions } from '../../types/permissions'; -import { PermissionDefinitions, PermissionGroup, Provider } from '../../types/types'; +import { PermissionDefinitions, PermissionGroup } from '../../types/types'; import GroupIcon from '../icons/GroupIcon'; import PermissionCell from './PermissionCell'; import usePermissionChange from './usePermissionChange'; @@ -37,30 +36,19 @@ interface Props { selectedPermission?: string; disabled?: boolean; removeOnly?: boolean; - isGitHubProject?: boolean; } export const ANYONE = 'Anyone'; export default function GroupHolder(props: Props) { - const { - group, - isComponentPrivate, - permissions, - selectedPermission, - disabled, - removeOnly, - isGitHubProject, - } = props; + const { group, isComponentPrivate, permissions, selectedPermission, disabled, removeOnly } = + props; const { loading, handleCheck, modal } = usePermissionChange({ holder: group, onToggle: props.onToggle, permissions, removeOnly, }); - const { data: identityProvider } = useIdentityProviderQuery({ - enabled: isGitHubProject ?? false, - }); const description = group.name === ANYONE ? translate('user_groups.anyone.description') : group.description; @@ -75,17 +63,15 @@ export default function GroupHolder(props: Props) {
{group.name}
- {isGitHubProject && - identityProvider?.provider === Provider.Github && - group.managed && ( - github - )} + {disabled && ( + github + )} {group.name === ANYONE && ( {translate('deprecated')} diff --git a/server/sonar-web/src/main/js/components/permissions/HoldersList.tsx b/server/sonar-web/src/main/js/components/permissions/HoldersList.tsx index f57f7ee9126..30b1afe643b 100644 --- a/server/sonar-web/src/main/js/components/permissions/HoldersList.tsx +++ b/server/sonar-web/src/main/js/components/permissions/HoldersList.tsx @@ -123,7 +123,6 @@ export default class HoldersList extends React.PureComponent< user={item} disabled={isGitHubProject && !!githubProvisioningStatus && item.managed} removeOnly={isGitHubProject && !!githubProvisioningStatus && !item.managed} - isGitHubProject={isGitHubProject} /> ) : ( )} diff --git a/server/sonar-web/src/main/js/components/permissions/UserHolder.tsx b/server/sonar-web/src/main/js/components/permissions/UserHolder.tsx index 1f3bc7f1bce..e07c01b6f87 100644 --- a/server/sonar-web/src/main/js/components/permissions/UserHolder.tsx +++ b/server/sonar-web/src/main/js/components/permissions/UserHolder.tsx @@ -22,8 +22,7 @@ import * as React from 'react'; import { translate } from '../../helpers/l10n'; import { isPermissionDefinitionGroup } from '../../helpers/permissions'; import { getBaseUrl } from '../../helpers/system'; -import { useIdentityProviderQuery } from '../../queries/identity-provider/common'; -import { PermissionDefinitions, PermissionUser, Provider } from '../../types/types'; +import { PermissionDefinitions, PermissionUser } from '../../types/types'; import PermissionCell from './PermissionCell'; import usePermissionChange from './usePermissionChange'; @@ -32,22 +31,18 @@ interface Props { permissions: PermissionDefinitions; selectedPermission?: string; user: PermissionUser; - isGitHubProject?: boolean; disabled?: boolean; removeOnly?: boolean; } export default function UserHolder(props: Props) { - const { user, disabled, removeOnly, permissions, isGitHubProject, selectedPermission } = props; + const { user, disabled, removeOnly, permissions, selectedPermission } = props; const { loading, handleCheck, modal } = usePermissionChange({ holder: user, onToggle: props.onToggle, permissions, removeOnly, }); - const { data: identityProvider } = useIdentityProviderQuery({ - enabled: isGitHubProject ?? false, - }); const permissionCells = permissions.map((permission) => ( {user.name} {user.login} - {isGitHubProject && - identityProvider?.provider === Provider.Github && - user.managed && ( - github - )} + {disabled && ( + github + )} {user.email && (
-- 2.39.5