From 0b441036f5376642c5df0223f387b146d73e0b88 Mon Sep 17 00:00:00 2001 From: Pascal Mugnier Date: Mon, 8 Oct 2018 14:58:35 +0200 Subject: [PATCH] Hide plus menu when dropdown is empty --- .../js/app/components/nav/global/GlobalNav.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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 2c1aa0f6813..4e7138114d8 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 } from '../../../types'; +import { isLoggedIn, CurrentUser, AppState, hasGlobalPermission } from '../../../types'; import NavBar from '../../../../components/nav/NavBar'; import { lazyLoad } from '../../../../components/lazyLoad'; import { getCurrentUser, getAppState, Store } from '../../../../store/rootReducer'; @@ -52,6 +52,18 @@ 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 ( @@ -63,7 +75,7 @@ export class GlobalNav extends React.PureComponent { {isSonarCloud() && } - {isLoggedIn(this.props.currentUser) && ( + {this.shouldRenderNavPlus() && (