aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2018-10-23 16:03:27 +0200
committerEric Hartmann <hartmann.eric@gmail.com>2018-10-25 10:25:58 +0200
commitcefae4aca32d702db0effe3779dfd0a1e976f8cb (patch)
tree7e885f3c34fae182838c1b360bffd51169eccf19 /server/sonar-web/src/main/js
parentc48cbe97b53bafc03fe43dbb27d03aed9e9d2967 (diff)
downloadsonarqube-cefae4aca32d702db0effe3779dfd0a1e976f8cb.tar.gz
sonarqube-cefae4aca32d702db0effe3779dfd0a1e976f8cb.zip
SONAR-11358 hide analyze new project button for users without permission
Diffstat (limited to 'server/sonar-web/src/main/js')
-rw-r--r--server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx4
-rw-r--r--server/sonar-web/src/main/js/apps/projects/components/__tests__/EmptyInstance-test.tsx7
2 files changed, 8 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx b/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx
index 974d80815fb..5bbcfe9d14b 100644
--- a/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx
+++ b/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx
@@ -21,7 +21,7 @@ import * as React from 'react';
import * as PropTypes from 'prop-types';
import { translate } from '../../../helpers/l10n';
import { Button } from '../../../components/ui/buttons';
-import { Organization, CurrentUser, isLoggedIn } from '../../../app/types';
+import { Organization, CurrentUser, isLoggedIn, hasGlobalPermission } from '../../../app/types';
import { isSonarCloud } from '../../../helpers/system';
interface Props {
@@ -44,7 +44,7 @@ export default class EmptyInstance extends React.PureComponent<Props> {
const { currentUser, organization } = this.props;
const showNewProjectButton = isSonarCloud()
? organization && organization.canProvisionProjects
- : isLoggedIn(currentUser);
+ : isLoggedIn(currentUser) && hasGlobalPermission(currentUser, 'provisioning');
return (
<div className="projects-empty-list">
diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/EmptyInstance-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/EmptyInstance-test.tsx
index 8ecfec660f3..f982f6d7e48 100644
--- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/EmptyInstance-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/EmptyInstance-test.tsx
@@ -32,7 +32,12 @@ it('renders correctly for SQ', () => {
shallow(<EmptyInstance currentUser={{ isLoggedIn: false }} organization={undefined} />)
).toMatchSnapshot();
expect(
- shallow(<EmptyInstance currentUser={{ isLoggedIn: true }} organization={undefined} />)
+ shallow(
+ <EmptyInstance
+ currentUser={{ isLoggedIn: true, permissions: { global: ['provisioning'] } }}
+ organization={undefined}
+ />
+ )
).toMatchSnapshot();
});