aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Mugnier <pascal.mugnier@sonarsource.com>2018-10-08 14:58:35 +0200
committerSonarTech <sonartech@sonarsource.com>2018-10-10 20:20:58 +0200
commit0b441036f5376642c5df0223f387b146d73e0b88 (patch)
tree23ebc49b6f3eef8ba411385cc38c4d30803430f6
parent924ce6095da8a1116727639e2c3771a4d5dc391f (diff)
downloadsonarqube-0b441036f5376642c5df0223f387b146d73e0b88.tar.gz
sonarqube-0b441036f5376642c5df0223f387b146d73e0b88.zip
Hide plus menu when dropdown is empty
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx16
1 files 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<Props> {
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 (
<NavBar className="navbar-global" height={theme.globalNavHeightRaw} id="global-navigation">
@@ -63,7 +75,7 @@ export class GlobalNav extends React.PureComponent<Props> {
{isSonarCloud() && <GlobalNavExplore location={this.props.location} />}
<EmbedDocsPopupHelper suggestions={this.props.suggestions} />
<Search appState={this.props.appState} currentUser={this.props.currentUser} />
- {isLoggedIn(this.props.currentUser) && (
+ {this.shouldRenderNavPlus() && (
<GlobalNavPlus
appState={this.props.appState}
currentUser={this.props.currentUser}