aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2017-02-10 16:08:30 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-02-10 23:48:03 +0100
commit419ce712fd40f8e38766cd93f7f35cb011533171 (patch)
treeb46eaa701bdf1188deb2a5a02110e5537889eef2
parent3aa5bd0d9cdf8afb5a99831d0804189e65a9ff23 (diff)
downloadsonarqube-419ce712fd40f8e38766cd93f7f35cb011533171.tar.gz
sonarqube-419ce712fd40f8e38766cd93f7f35cb011533171.zip
SONAR-8655 check `canDelete`flag
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/components/OrganizationPage.js2
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.js13
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigation-test.js11
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigation-test.js.snap103
-rw-r--r--server/sonar-web/src/main/js/store/organizations/duck.js3
5 files changed, 123 insertions, 9 deletions
diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPage.js b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPage.js
index 19670aafb46..a6a2e82f165 100644
--- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPage.js
+++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPage.js
@@ -61,7 +61,7 @@ class OrganizationPage extends React.Component {
render () {
const { organization } = this.props;
- if (!organization || organization.isDefault == null) {
+ if (!organization || organization.canAdmin == null) {
if (this.state.loading) {
return null;
} else {
diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.js b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.js
index 21b1ab8d074..ae69f59d20b 100644
--- a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.js
+++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.js
@@ -41,6 +41,7 @@ export default class OrganizationNavigation extends React.Component {
key: string,
name: string,
canAdmin?: boolean,
+ canDelete?: boolean,
url?: string
}
};
@@ -83,11 +84,13 @@ export default class OrganizationNavigation extends React.Component {
{translate('edit')}
</Link>
</li>
- <li>
- <Link to={`/organizations/${organization.key}/delete`} activeClassName="active">
- {translate('delete')}
- </Link>
- </li>
+ {organization.canDelete && (
+ <li>
+ <Link to={`/organizations/${organization.key}/delete`} activeClassName="active">
+ {translate('delete')}
+ </Link>
+ </li>
+ )}
</ul>
</li>
);
diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigation-test.js b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigation-test.js
index e31bc4e1bc1..20d01e6f04b 100644
--- a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigation-test.js
+++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigation-test.js
@@ -22,14 +22,21 @@ import { shallow } from 'enzyme';
import OrganizationNavigation from '../OrganizationNavigation';
it('regular user', () => {
- const organization = { key: 'foo', name: 'Foo', canAdmin: false };
+ const organization = { key: 'foo', name: 'Foo', canAdmin: false, canDelete: false };
expect(shallow(
<OrganizationNavigation location={{ pathname: '/organizations/foo' }} organization={organization}/>
)).toMatchSnapshot();
});
it('admin', () => {
- const organization = { key: 'foo', name: 'Foo', canAdmin: true };
+ const organization = { key: 'foo', name: 'Foo', canAdmin: true, canDelete: true };
+ expect(shallow(
+ <OrganizationNavigation location={{ pathname: '/organizations/foo' }} organization={organization}/>
+ )).toMatchSnapshot();
+});
+
+it('undeletable org', () => {
+ const organization = { key: 'foo', name: 'Foo', canAdmin: true, canDelete: false };
expect(shallow(
<OrganizationNavigation location={{ pathname: '/organizations/foo' }} organization={organization}/>
)).toMatchSnapshot();
diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigation-test.js.snap b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigation-test.js.snap
index 62d369ad119..02421f1020d 100644
--- a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigation-test.js.snap
+++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigation-test.js.snap
@@ -152,3 +152,106 @@ exports[`test regular user 1`] = `
</div>
</nav>
`;
+
+exports[`test undeletable org 1`] = `
+<nav
+ className="navbar navbar-context page-container"
+ id="context-navigation">
+ <div
+ className="navbar-context-inner">
+ <div
+ className="container">
+ <h2
+ className="navbar-context-title">
+ <span
+ className="navbar-context-title-qualifier little-spacer-right">
+ <OrganizationIcon />
+ </span>
+ <Link
+ className="link-base-color"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to="/organizations/foo">
+ <strong>
+ Foo
+ </strong>
+ </Link>
+ </h2>
+ <div
+ className="navbar-context-meta" />
+ <ul
+ className="nav navbar-nav nav-tabs">
+ <li>
+ <Link
+ className=""
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to="/organizations/foo/projects">
+ projects.page
+ </Link>
+ </li>
+ <li
+ className="">
+ <a
+ className="dropdown-toggle navbar-admin-link"
+ data-toggle="dropdown"
+ href="#">
+ layout.settings
+  
+ <i
+ className="icon-dropdown" />
+ </a>
+ <ul
+ className="dropdown-menu">
+ <li>
+ <Link
+ activeClassName="active"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to="/organizations/foo/groups">
+ user_groups.page
+ </Link>
+ </li>
+ <li>
+ <Link
+ activeClassName="active"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to="/organizations/foo/permissions">
+ permissions.page
+ </Link>
+ </li>
+ <li>
+ <Link
+ activeClassName="active"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to="/organizations/foo/permission_templates">
+ permission_templates
+ </Link>
+ </li>
+ <li>
+ <Link
+ activeClassName="active"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to="/organizations/foo/projects_management">
+ projects_management
+ </Link>
+ </li>
+ <li>
+ <Link
+ activeClassName="active"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to="/organizations/foo/edit">
+ edit
+ </Link>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+ </div>
+</nav>
+`;
diff --git a/server/sonar-web/src/main/js/store/organizations/duck.js b/server/sonar-web/src/main/js/store/organizations/duck.js
index fb25f1bfce1..f1d4a1b5b7b 100644
--- a/server/sonar-web/src/main/js/store/organizations/duck.js
+++ b/server/sonar-web/src/main/js/store/organizations/duck.js
@@ -26,8 +26,9 @@ import without from 'lodash/without';
export type Organization = {
avatar?: string,
canAdmin?: boolean,
+ canDelete?: boolean,
+ canProvisionProjects?: boolean,
description?: string,
- isDefault?: boolean,
key: string,
name: string,
url?: string