aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/components')
-rw-r--r--server/sonar-web/src/main/js/components/permissions/GroupHolder.tsx39
-rw-r--r--server/sonar-web/src/main/js/components/permissions/HoldersList.tsx77
-rw-r--r--server/sonar-web/src/main/js/components/permissions/UserHolder.tsx28
3 files changed, 105 insertions, 39 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 19b3369f9fe..1c2e15b7a0a 100644
--- a/server/sonar-web/src/main/js/components/permissions/GroupHolder.tsx
+++ b/server/sonar-web/src/main/js/components/permissions/GroupHolder.tsx
@@ -21,7 +21,7 @@
import { Badge, ContentCell, TableRowInteractive, UserGroupIcon } from 'design-system';
import * as React from 'react';
import { Image } from '~sonar-aligned/components/common/Image';
-import { translate } from '../../helpers/l10n';
+import { translate, translateWithParameters } from '../../helpers/l10n';
import { isPermissionDefinitionGroup } from '../../helpers/permissions';
import { isDefined } from '../../helpers/types';
import { Permissions } from '../../types/permissions';
@@ -30,9 +30,10 @@ import PermissionCell from './PermissionCell';
import usePermissionChange from './usePermissionChange';
interface Props {
- disabled?: boolean;
group: PermissionGroup;
isComponentPrivate?: boolean;
+ isGitHubUser: boolean | undefined;
+ isGitLabUser: boolean | undefined;
onToggle: (group: PermissionGroup, permission: string) => Promise<void>;
permissions: PermissionDefinitions;
removeOnly?: boolean;
@@ -42,8 +43,15 @@ interface Props {
export const ANYONE = 'Anyone';
export default function GroupHolder(props: Props) {
- const { group, isComponentPrivate, permissions, selectedPermission, disabled, removeOnly } =
- props;
+ const {
+ group,
+ isComponentPrivate,
+ permissions,
+ selectedPermission,
+ removeOnly,
+ isGitHubUser,
+ isGitLabUser,
+ } = props;
const { loading, handleCheck, modal } = usePermissionChange({
holder: group,
onToggle: props.onToggle,
@@ -64,15 +72,30 @@ 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>
- {disabled && (
+ {isGitHubUser && (
<Image
alt="github"
className="sw-ml-2"
- aria-label={translate('project_permission.github_managed')}
+ aria-label={translateWithParameters(
+ 'project_permission.managed',
+ translate('alm.github'),
+ )}
height={16}
src="/images/alm/github.svg"
/>
)}
+ {isGitLabUser && (
+ <Image
+ alt="gitlab"
+ className="sw-ml-2"
+ aria-label={translateWithParameters(
+ 'project_permission.managed',
+ translate('alm.gitlab'),
+ )}
+ height={16}
+ src="/images/alm/gitlab.svg"
+ />
+ )}
{group.name === ANYONE && (
<Badge className="sw-ml-2" variant="deleted">
{translate('deprecated')}
@@ -93,7 +116,9 @@ export default function GroupHolder(props: Props) {
return (
<PermissionCell
disabled={
- disabled || (group.name === ANYONE && (isComponentPrivate || isAdminPermission))
+ isGitHubUser ||
+ isGitLabUser ||
+ (group.name === ANYONE && (isComponentPrivate || isAdminPermission))
}
removeOnly={removeOnly}
key={permissionKey}
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 30b1afe643b..82482841c02 100644
--- a/server/sonar-web/src/main/js/components/permissions/HoldersList.tsx
+++ b/server/sonar-web/src/main/js/components/permissions/HoldersList.tsx
@@ -23,8 +23,9 @@ import * as React from 'react';
import UseQuery from '../../helpers/UseQuery';
import { translate } from '../../helpers/l10n';
import { isPermissionDefinitionGroup } from '../../helpers/permissions';
-import { useIsGitHubProjectQuery } from '../../queries/devops-integration';
+import { useIsGitHubProjectQuery, useIsGitLabProjectQuery } from '../../queries/devops-integration';
import { useGithubProvisioningEnabledQuery } from '../../queries/identity-provider/github';
+import { useGilabProvisioningEnabledQuery } from '../../queries/identity-provider/gitlab';
import { Dict, PermissionDefinitions, PermissionGroup, PermissionUser } from '../../types/types';
import GroupHolder from './GroupHolder';
import PermissionHeader from './PermissionHeader';
@@ -111,32 +112,56 @@ export default class HoldersList extends React.PureComponent<
return (
<UseQuery key={this.getKey(item)} query={useIsGitHubProjectQuery}>
{({ data: isGitHubProject }) => (
- <UseQuery query={useGithubProvisioningEnabledQuery}>
- {({ data: githubProvisioningStatus }) => (
- <>
- {this.isPermissionUser(item) ? (
- <UserHolder
- key={`user-${item.login}`}
- onToggle={this.handleUserToggle}
- permissions={permissions}
- selectedPermission={selectedPermission}
- user={item}
- disabled={isGitHubProject && !!githubProvisioningStatus && item.managed}
- removeOnly={isGitHubProject && !!githubProvisioningStatus && !item.managed}
- />
- ) : (
- <GroupHolder
- group={item}
- isComponentPrivate={isComponentPrivate}
- key={`group-${item.id || item.name}`}
- onToggle={this.handleGroupToggle}
- permissions={permissions}
- selectedPermission={selectedPermission}
- disabled={isGitHubProject && !!githubProvisioningStatus && item.managed}
- removeOnly={isGitHubProject && !!githubProvisioningStatus && !item.managed}
- />
+ <UseQuery key={this.getKey(item)} query={useIsGitLabProjectQuery}>
+ {({ data: isGitLabProject }) => (
+ <UseQuery query={useGilabProvisioningEnabledQuery}>
+ {({ data: gitlabProvisioningStatus }) => (
+ <UseQuery query={useGithubProvisioningEnabledQuery}>
+ {({ data: githubProvisioningStatus }) => (
+ <>
+ {this.isPermissionUser(item) ? (
+ <UserHolder
+ key={`user-${item.login}`}
+ onToggle={this.handleUserToggle}
+ permissions={permissions}
+ selectedPermission={selectedPermission}
+ user={item}
+ isGitHubUser={
+ isGitHubProject && !!githubProvisioningStatus && item.managed
+ }
+ isGitLabUser={
+ isGitLabProject && !!gitlabProvisioningStatus && item.managed
+ }
+ removeOnly={
+ (isGitHubProject && !!githubProvisioningStatus && !item.managed) ||
+ (isGitLabProject && !!gitlabProvisioningStatus && !item.managed)
+ }
+ />
+ ) : (
+ <GroupHolder
+ group={item}
+ isComponentPrivate={isComponentPrivate}
+ key={`group-${item.id || item.name}`}
+ onToggle={this.handleGroupToggle}
+ permissions={permissions}
+ selectedPermission={selectedPermission}
+ isGitHubUser={
+ isGitHubProject && !!githubProvisioningStatus && item.managed
+ }
+ isGitLabUser={
+ isGitLabProject && !!gitlabProvisioningStatus && item.managed
+ }
+ removeOnly={
+ (isGitHubProject && !!githubProvisioningStatus && !item.managed) ||
+ (isGitLabProject && !!gitlabProvisioningStatus && !item.managed)
+ }
+ />
+ )}
+ </>
+ )}
+ </UseQuery>
)}
- </>
+ </UseQuery>
)}
</UseQuery>
)}
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 b0088590290..a3f2133775a 100644
--- a/server/sonar-web/src/main/js/components/permissions/UserHolder.tsx
+++ b/server/sonar-web/src/main/js/components/permissions/UserHolder.tsx
@@ -21,7 +21,7 @@
import { Avatar, ContentCell, Note, TableRowInteractive } from 'design-system';
import * as React from 'react';
import { Image } from '~sonar-aligned/components/common/Image';
-import { translate } from '../../helpers/l10n';
+import { translate, translateWithParameters } from '../../helpers/l10n';
import { isPermissionDefinitionGroup } from '../../helpers/permissions';
import { isDefined } from '../../helpers/types';
import { PermissionDefinitions, PermissionUser } from '../../types/types';
@@ -29,7 +29,8 @@ import PermissionCell from './PermissionCell';
import usePermissionChange from './usePermissionChange';
interface Props {
- disabled?: boolean;
+ isGitHubUser: boolean | undefined;
+ isGitLabUser: boolean | undefined;
onToggle: (user: PermissionUser, permission: string) => Promise<void>;
permissions: PermissionDefinitions;
removeOnly?: boolean;
@@ -38,7 +39,7 @@ interface Props {
}
export default function UserHolder(props: Props) {
- const { user, disabled, removeOnly, permissions, selectedPermission } = props;
+ const { user, removeOnly, permissions, selectedPermission, isGitHubUser, isGitLabUser } = props;
const { loading, handleCheck, modal } = usePermissionChange({
holder: user,
onToggle: props.onToggle,
@@ -52,7 +53,7 @@ export default function UserHolder(props: Props) {
loading={loading}
onCheck={handleCheck}
permission={permission}
- disabled={disabled}
+ disabled={isGitHubUser || isGitLabUser}
removeOnly={removeOnly}
permissionItem={user}
prefixID={user.login}
@@ -91,15 +92,30 @@ export default function UserHolder(props: Props) {
<strong>{user.name}</strong>
<Note className="sw-ml-2">{user.login}</Note>
</div>
- {disabled && (
+ {isGitHubUser && (
<Image
alt="github"
className="sw-ml-2"
height={16}
- aria-label={translate('project_permission.github_managed')}
+ aria-label={translateWithParameters(
+ 'project_permission.managed',
+ translate('alm.github'),
+ )}
src="/images/alm/github.svg"
/>
)}
+ {isGitLabUser && (
+ <Image
+ alt="gitlab"
+ className="sw-ml-2"
+ height={16}
+ aria-label={translateWithParameters(
+ 'project_permission.managed',
+ translate('alm.gitlab'),
+ )}
+ src="/images/alm/gitlab.svg"
+ />
+ )}
</div>
{isDefined(user.email) && (
<div className="sw-mt-2 sw-max-w-100 sw-text-ellipsis sw-whitespace-nowrap sw-overflow-hidden">