aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/permissions
diff options
context:
space:
mode:
authorJeremy Davis <jeremy.davis@sonarsource.com>2024-03-05 14:39:48 +0100
committersonartech <sonartech@sonarsource.com>2024-03-06 20:02:33 +0000
commit1b3309384e107beef6be6fe96df4de30c5db824e (patch)
tree8f8e2479bf1edd99f022f39fd8a9c9c8ed94f865 /server/sonar-web/src/main/js/components/permissions
parent8b8a4c777ec1c680c5018f4d8324d38a7d3fb11a (diff)
downloadsonarqube-1b3309384e107beef6be6fe96df4de30c5db824e.tar.gz
sonarqube-1b3309384e107beef6be6fe96df4de30c5db824e.zip
SONAR-21642 Fix project permissions for project admin
Diffstat (limited to 'server/sonar-web/src/main/js/components/permissions')
-rw-r--r--server/sonar-web/src/main/js/components/permissions/GroupHolder.tsx38
-rw-r--r--server/sonar-web/src/main/js/components/permissions/HoldersList.tsx2
-rw-r--r--server/sonar-web/src/main/js/components/permissions/UserHolder.tsx29
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) {
<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')}
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}
/>
) : (
<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}
/>
)}
</>
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) => (
<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">