From cefae4aca32d702db0effe3779dfd0a1e976f8cb Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 23 Oct 2018 16:03:27 +0200 Subject: SONAR-11358 hide analyze new project button for users without permission --- .../src/main/js/apps/projects/components/EmptyInstance.tsx | 4 ++-- .../js/apps/projects/components/__tests__/EmptyInstance-test.tsx | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'server/sonar-web/src/main/js') 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 { const { currentUser, organization } = this.props; const showNewProjectButton = isSonarCloud() ? organization && organization.canProvisionProjects - : isLoggedIn(currentUser); + : isLoggedIn(currentUser) && hasGlobalPermission(currentUser, 'provisioning'); return (
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() ).toMatchSnapshot(); expect( - shallow() + shallow( + + ) ).toMatchSnapshot(); }); -- cgit v1.2.3