From: Grégoire Aubert Date: Thu, 11 Oct 2018 15:09:18 +0000 (+0200) Subject: SONAR-11289 Always display plus menu on SonarCloud X-Git-Tag: 7.5~297 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f0350c5cf3622e723e79e4ea7695741a47c0dbe2;p=sonarqube.git SONAR-11289 Always display plus menu on SonarCloud --- diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx index 4e7138114d8..513ee90f6d9 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx @@ -27,7 +27,7 @@ import GlobalNavUserContainer from './GlobalNavUserContainer'; import Search from '../../search/Search'; import EmbedDocsPopupHelper from '../../embed-docs-modal/EmbedDocsPopupHelper'; import * as theme from '../../../theme'; -import { isLoggedIn, CurrentUser, AppState, hasGlobalPermission } from '../../../types'; +import { CurrentUser, AppState } from '../../../types'; import NavBar from '../../../../components/nav/NavBar'; import { lazyLoad } from '../../../../components/lazyLoad'; import { getCurrentUser, getAppState, Store } from '../../../../store/rootReducer'; @@ -52,18 +52,6 @@ type Props = StateProps & OwnProps; export class GlobalNav extends React.PureComponent { static contextTypes = { openProjectOnboarding: PropTypes.func }; - shouldRenderNavPlus = () => { - const { currentUser } = this.props; - if (!isLoggedIn(currentUser)) { - return false; - } - return ( - hasGlobalPermission(currentUser, 'provisioning') || - hasGlobalPermission(currentUser, 'applicationcreator') || - hasGlobalPermission(currentUser, 'portfoliocreator') - ); - }; - render() { return ( @@ -75,13 +63,11 @@ export class GlobalNav extends React.PureComponent { {isSonarCloud() && } - {this.shouldRenderNavPlus() && ( - - )} + diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx index 47a424a0e54..9da8d2ac45d 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx @@ -98,9 +98,8 @@ export class GlobalNavPlus extends React.PureComponent - {this.renderCreateProject()} - {this.renderCreateOrganization()} + {this.renderCreateProject(canCreateProject)} + {this.renderCreateOrganization(canCreateOrg)} {this.renderCreatePortfolio( canCreateApplication || canCreatePortfolio, defaultQualifier diff --git a/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavPlus-test.tsx b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavPlus-test.tsx index b74fe72c299..b4a77bf8216 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavPlus-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavPlus-test.tsx @@ -52,6 +52,11 @@ it('should display create new organization on SonarCloud only', () => { expect(getOverlayWrapper(getWrapper())).toMatchSnapshot(); }); +it('should display new organization and new project on SonarCloud', () => { + (isSonarCloud as jest.Mock).mockReturnValue(true); + expect(getOverlayWrapper(getWrapper({}, []))).toMatchSnapshot(); +}); + it('should display create portfolio and application', () => { checkOpenCreatePortfolio(['applicationcreator', 'portfoliocreator'], undefined); }); diff --git a/server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNav-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNav-test.tsx.snap index 62c2757d57b..f785691d515 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNav-test.tsx.snap +++ b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNav-test.tsx.snap @@ -56,6 +56,21 @@ exports[`should render for SonarCloud 1`] = ` } } /> + + `; + +exports[`should display new organization and new project on SonarCloud 1`] = ` + +`;