]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21642 Fix project permissions for project admin
authorJeremy Davis <jeremy.davis@sonarsource.com>
Tue, 5 Mar 2024 13:39:48 +0000 (14:39 +0100)
committersonartech <sonartech@sonarsource.com>
Wed, 6 Mar 2024 20:02:33 +0000 (20:02 +0000)
server/sonar-web/src/main/js/components/permissions/GroupHolder.tsx
server/sonar-web/src/main/js/components/permissions/HoldersList.tsx
server/sonar-web/src/main/js/components/permissions/UserHolder.tsx

index f1a56da82f1ea7995c58cf4361cadf01f9b2dc31..d2a1a874c6ad5be49450a7cbd1be02738b74a1a4 100644 (file)
@@ -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) {
               <div className="sw-flex-1 sw-text-ellipsis sw-whitespace-nowrap sw-overflow-hidden  sw-min-w-0">
                 <strong>{group.name}</strong>
               </div>
-              {isGitHubProject &&
-                identityProvider?.provider === Provider.Github &&
-                group.managed && (
-                  <img
-                    alt="github"
-                    className="sw-ml-2"
-                    aria-label={translate('project_permission.github_managed')}
-                    height={16}
-                    src={`${getBaseUrl()}/images/alm/github.svg`}
-                  />
-                )}
+              {disabled && (
+                <img
+                  alt="github"
+                  className="sw-ml-2"
+                  aria-label={translate('project_permission.github_managed')}
+                  height={16}
+                  src={`${getBaseUrl()}/images/alm/github.svg`}
+                />
+              )}
               {group.name === ANYONE && (
                 <Badge className="sw-ml-2" variant="deleted">
                   {translate('deprecated')}
index f57f7ee912683ff6591bac29329d496031efa3ca..30b1afe643b677d9066c8abb04a6a922c7b05501 100644 (file)
@@ -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}
                   />
                 ) : (
                   <GroupHolder
@@ -135,7 +134,6 @@ export default class HoldersList extends React.PureComponent<
                     selectedPermission={selectedPermission}
                     disabled={isGitHubProject && !!githubProvisioningStatus && item.managed}
                     removeOnly={isGitHubProject && !!githubProvisioningStatus && !item.managed}
-                    isGitHubProject={isGitHubProject}
                   />
                 )}
               </>
index 1f3bc7f1bce0db24f72a67bb9608932a12ff1339..e07c01b6f872cc57b8abc6dc28a7e011d09f2660 100644 (file)
@@ -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) => (
     <PermissionCell
@@ -94,17 +89,15 @@ export default function UserHolder(props: Props) {
                 <strong>{user.name}</strong>
                 <Note className="sw-ml-2">{user.login}</Note>
               </div>
-              {isGitHubProject &&
-                identityProvider?.provider === Provider.Github &&
-                user.managed && (
-                  <img
-                    alt="github"
-                    className="sw-ml-2"
-                    height={16}
-                    aria-label={translate('project_permission.github_managed')}
-                    src={`${getBaseUrl()}/images/alm/github.svg`}
-                  />
-                )}
+              {disabled && (
+                <img
+                  alt="github"
+                  className="sw-ml-2"
+                  height={16}
+                  aria-label={translate('project_permission.github_managed')}
+                  src={`${getBaseUrl()}/images/alm/github.svg`}
+                />
+              )}
             </div>
             {user.email && (
               <div className="sw-mt-2 sw-max-w-100 sw-text-ellipsis sw-whitespace-nowrap sw-overflow-hidden">