aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2018-10-11 17:09:18 +0200
committerSonarTech <sonartech@sonarsource.com>2018-10-12 20:20:58 +0200
commitf0350c5cf3622e723e79e4ea7695741a47c0dbe2 (patch)
tree5a4d691d324cf7712d30703a2a4ac606ff17f28e /server/sonar-web/src/main/js
parentf9bb435740391633129ceee0732c531942e48115 (diff)
downloadsonarqube-f0350c5cf3622e723e79e4ea7695741a47c0dbe2.tar.gz
sonarqube-f0350c5cf3622e723e79e4ea7695741a47c0dbe2.zip
SONAR-11289 Always display plus menu on SonarCloud
Diffstat (limited to 'server/sonar-web/src/main/js')
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx26
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx18
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavPlus-test.tsx5
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNav-test.tsx.snap30
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNavPlus-test.tsx.snap26
5 files changed, 76 insertions, 29 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 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<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">
@@ -75,13 +63,11 @@ 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} />
- {this.shouldRenderNavPlus() && (
- <GlobalNavPlus
- appState={this.props.appState}
- currentUser={this.props.currentUser}
- openProjectOnboarding={this.context.openProjectOnboarding}
- />
- )}
+ <GlobalNavPlus
+ appState={this.props.appState}
+ currentUser={this.props.currentUser}
+ openProjectOnboarding={this.context.openProjectOnboarding}
+ />
<GlobalNavUserContainer {...this.props} />
</ul>
</NavBar>
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<Props & WithRouterProps,
});
};
- renderCreateProject() {
- const { currentUser } = this.props;
- if (!hasGlobalPermission(currentUser, 'provisioning')) {
+ renderCreateProject(canCreateProject: boolean) {
+ if (!canCreateProject) {
return null;
}
return (
@@ -112,8 +111,8 @@ export class GlobalNavPlus extends React.PureComponent<Props & WithRouterProps,
);
}
- renderCreateOrganization() {
- if (!isSonarCloud()) {
+ renderCreateOrganization(canCreateOrg: boolean) {
+ if (!canCreateOrg) {
return null;
}
@@ -145,11 +144,12 @@ export class GlobalNavPlus extends React.PureComponent<Props & WithRouterProps,
render() {
const { currentUser } = this.props;
- const canCreateProject = hasGlobalPermission(currentUser, 'provisioning');
const canCreateApplication = hasGlobalPermission(currentUser, 'applicationcreator');
+ const canCreateOrg = isSonarCloud();
const canCreatePortfolio = hasGlobalPermission(currentUser, 'portfoliocreator');
+ const canCreateProject = isSonarCloud() || hasGlobalPermission(currentUser, 'provisioning');
- if (!canCreateProject && !canCreateApplication && !canCreatePortfolio) {
+ if (!canCreateProject && !canCreateApplication && !canCreatePortfolio && !canCreateOrg) {
return null;
}
@@ -165,8 +165,8 @@ export class GlobalNavPlus extends React.PureComponent<Props & WithRouterProps,
<Dropdown
overlay={
<ul className="menu">
- {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`] = `
}
}
/>
+ <LazyLoader
+ appState={
+ Object {
+ "canAdmin": false,
+ "globalPages": Array [],
+ "organizationsEnabled": false,
+ "qualifiers": Array [],
+ }
+ }
+ currentUser={
+ Object {
+ "isLoggedIn": false,
+ }
+ }
+ />
<Connect(GlobalNavUser)
appState={
Object {
@@ -130,6 +145,21 @@ exports[`should render for SonarQube 1`] = `
}
}
/>
+ <LazyLoader
+ appState={
+ Object {
+ "canAdmin": false,
+ "globalPages": Array [],
+ "organizationsEnabled": false,
+ "qualifiers": Array [],
+ }
+ }
+ currentUser={
+ Object {
+ "isLoggedIn": false,
+ }
+ }
+ />
<Connect(GlobalNavUser)
appState={
Object {
diff --git a/server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNavPlus-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNavPlus-test.tsx.snap
index a54b7dfefcb..0660c2be47c 100644
--- a/server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNavPlus-test.tsx.snap
+++ b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNavPlus-test.tsx.snap
@@ -84,3 +84,29 @@ exports[`should display create portfolio and application 1`] = `
my_account.create_new_portfolio_application
</a>
`;
+
+exports[`should display new organization and new project on SonarCloud 1`] = `
+<ul
+ className="menu"
+>
+ <li>
+ <a
+ className="js-new-project"
+ href="#"
+ onClick={[Function]}
+ >
+ provisioning.create_new_project
+ </a>
+ </li>
+ <li>
+ <Link
+ className="js-new-organization"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to="/create-organization"
+ >
+ my_account.create_new_organization
+ </Link>
+ </li>
+</ul>
+`;