aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-11-30 11:25:53 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2017-12-14 17:03:35 +0100
commit42b5ea685c8ee46cf05625879300aa3eb3529897 (patch)
tree80a8d137148baf376888fe2092875ea6682a0516 /server
parentc4b2c3d7050c3639ec7672e1ba8b6dd266bd59dc (diff)
downloadsonarqube-42b5ea685c8ee46cf05625879300aa3eb3529897.tar.gz
sonarqube-42b5ea685c8ee46cf05625879300aa3eb3529897.zip
Rewrite usage of Organization containers
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/js/api/users.ts4
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavUser-test.tsx7
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/components/OrganizationAdminContainer.tsx (renamed from server/sonar-web/src/main/js/apps/organizations/components/OrganizationAdmin.js)39
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/components/OrganizationContainer.tsx (renamed from server/sonar-web/src/main/js/apps/organizations/components/OrganizationContainer.js)23
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/components/OrganizationDelete.js6
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/components/OrganizationEdit.js6
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/components/OrganizationGroups.js10
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/components/OrganizationPermissionTemplates.js42
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/components/OrganizationPermissions.tsx38
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/components/OrganizationProjectsManagement.js41
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationAdmin-test.js46
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationAdminContainer-test.tsx60
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/components/__tests__/__snapshots__/OrganizationAdmin-test.js.snap7
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/components/__tests__/__snapshots__/OrganizationAdminContainer-test.tsx.snap17
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigation-test.tsx.snap3
-rw-r--r--server/sonar-web/src/main/js/apps/organizations/routes.ts (renamed from server/sonar-web/src/main/js/apps/organizations/routes.js)17
-rw-r--r--server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx4
18 files changed, 139 insertions, 234 deletions
diff --git a/server/sonar-web/src/main/js/api/users.ts b/server/sonar-web/src/main/js/api/users.ts
index d04b71bcd55..fa1b73f80fa 100644
--- a/server/sonar-web/src/main/js/api/users.ts
+++ b/server/sonar-web/src/main/js/api/users.ts
@@ -19,7 +19,7 @@
*/
import { getJSON, post, postJSON, RequestData } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
-import { Paging } from '../app/types';
+import { CurrentUser, Paging } from '../app/types';
export interface IdentityProvider {
backgroundColor: string;
@@ -42,7 +42,7 @@ export interface User {
avatar?: string;
}
-export function getCurrentUser(): Promise<any> {
+export function getCurrentUser(): Promise<CurrentUser> {
return getJSON('/api/users/current');
}
diff --git a/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavUser-test.tsx b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavUser-test.tsx
index 1ffec34be8f..90cf0393293 100644
--- a/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavUser-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavUser-test.tsx
@@ -20,12 +20,13 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import GlobalNavUser from '../GlobalNavUser';
+import { Visibility } from '../../../../types';
const currentUser = { avatar: 'abcd1234', isLoggedIn: true, name: 'foo', email: 'foo@bar.baz' };
const organizations = [
- { key: 'myorg', name: 'MyOrg', projectVisibility: 'public' },
- { key: 'foo', name: 'Foo', projectVisibility: 'public' },
- { key: 'bar', name: 'bar', projectVisibility: 'public' }
+ { key: 'myorg', name: 'MyOrg', projectVisibility: Visibility.Public },
+ { key: 'foo', name: 'Foo', projectVisibility: Visibility.Public },
+ { key: 'bar', name: 'bar', projectVisibility: Visibility.Public }
];
const appState = { organizationsEnabled: true };
diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationAdmin.js b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationAdminContainer.tsx
index d11ba3c3d5b..393c1768dc1 100644
--- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationAdmin.js
+++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationAdminContainer.tsx
@@ -17,19 +17,24 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-// @flow
-import React from 'react';
+import * as React from 'react';
import { connect } from 'react-redux';
+import { RouterState } from 'react-router';
import { getOrganizationByKey } from '../../../store/rootReducer';
import handleRequiredAuthorization from '../../../app/utils/handleRequiredAuthorization';
+import { Organization } from '../../../app/types';
-export class OrganizationAdmin extends React.PureComponent {
- /*:: props: {
- children?: React.Element<*>,
- organization: { canAdmin: boolean }
- };
- */
+interface StateToProps {
+ organization?: Organization;
+}
+
+interface OwnProps extends RouterState {
+ children: JSX.Element;
+}
+
+interface Props extends StateToProps, Pick<OwnProps, 'children' | 'location'> {}
+export class OrganizationAdmin extends React.PureComponent<Props> {
componentDidMount() {
this.checkPermissions();
}
@@ -38,27 +43,27 @@ export class OrganizationAdmin extends React.PureComponent {
this.checkPermissions();
}
- isOrganizationAdmin() {
- return this.props.organization.canAdmin;
- }
+ isOrganizationAdmin = () => this.props.organization && this.props.organization.canAdmin;
- checkPermissions() {
+ checkPermissions = () => {
if (!this.isOrganizationAdmin()) {
handleRequiredAuthorization();
}
- }
+ };
render() {
if (!this.isOrganizationAdmin()) {
return null;
}
-
- return this.props.children;
+ return React.cloneElement(this.props.children, {
+ location: this.props.location,
+ organization: this.props.organization
+ });
}
}
-const mapStateToProps = (state, ownProps) => ({
+const mapStateToProps = (state: any, ownProps: OwnProps) => ({
organization: getOrganizationByKey(state, ownProps.params.organizationKey)
});
-export default connect(mapStateToProps)(OrganizationAdmin);
+export default connect<StateToProps, {}, OwnProps>(mapStateToProps)(OrganizationAdmin);
diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationContainer.js b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationContainer.tsx
index a48cf7f5cd6..01b44ca1feb 100644
--- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationContainer.js
+++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationContainer.tsx
@@ -17,23 +17,36 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-//@flow
-import React from 'react';
+import * as React from 'react';
import { connect } from 'react-redux';
+import { RouterState } from 'react-router';
import { getCurrentUser, getOrganizationByKey } from '../../../store/rootReducer';
+import { Organization, CurrentUser } from '../../../app/types';
-class OrganizationContainer extends React.PureComponent {
+interface StateToProps {
+ organization?: Organization;
+ currentUser: CurrentUser;
+}
+
+interface OwnProps extends RouterState {
+ children: JSX.Element;
+}
+
+interface Props extends StateToProps, Pick<OwnProps, 'children' | 'location'> {}
+
+class OrganizationContainer extends React.PureComponent<Props> {
render() {
return React.cloneElement(this.props.children, {
+ location: this.props.location,
currentUser: this.props.currentUser,
organization: this.props.organization
});
}
}
-const mapStateToProps = (state, ownProps) => ({
+const mapStateToProps = (state: any, ownProps: OwnProps) => ({
organization: getOrganizationByKey(state, ownProps.params.organizationKey),
currentUser: getCurrentUser(state)
});
-export default connect(mapStateToProps)(OrganizationContainer);
+export default connect<StateToProps, {}, OwnProps>(mapStateToProps)(OrganizationContainer);
diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationDelete.js b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationDelete.js
index d1b270dd0d4..cf91c1e61b9 100644
--- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationDelete.js
+++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationDelete.js
@@ -115,12 +115,8 @@ class OrganizationDelete extends React.PureComponent {
}
}
-const mapStateToProps = (state, ownProps) => ({
- organization: getOrganizationByKey(state, ownProps.params.organizationKey)
-});
-
const mapDispatchToProps = { deleteOrganization };
-export default connect(mapStateToProps, mapDispatchToProps)(withRouter(OrganizationDelete));
+export default connect(null, mapDispatchToProps)(withRouter(OrganizationDelete));
export const UnconnectedOrganizationDelete = OrganizationDelete;
diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationEdit.js b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationEdit.js
index 22ea72f7c6a..5f7a3c867ef 100644
--- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationEdit.js
+++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationEdit.js
@@ -193,12 +193,8 @@ class OrganizationEdit extends React.PureComponent {
}
}
-const mapStateToProps = (state, ownProps) => ({
- organization: getOrganizationByKey(state, ownProps.params.organizationKey)
-});
-
const mapDispatchToProps = { updateOrganization };
-export default connect(mapStateToProps, mapDispatchToProps)(OrganizationEdit);
+export default connect(null, mapDispatchToProps)(OrganizationEdit);
export const UnconnectedOrganizationEdit = OrganizationEdit;
diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationGroups.js b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationGroups.js
index 4d46eedb5b1..984c4c8d6ca 100644
--- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationGroups.js
+++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationGroups.js
@@ -20,13 +20,11 @@
// @flow
import React from 'react';
import Helmet from 'react-helmet';
-import { connect } from 'react-redux';
import init from '../../groups/init';
-import { getOrganizationByKey } from '../../../store/rootReducer';
import { translate } from '../../../helpers/l10n';
/*:: import type { Organization } from '../../../store/organizations/duck'; */
-class OrganizationGroups extends React.PureComponent {
+export default class OrganizationGroups extends React.PureComponent {
/*:: props: {
organization: Organization
};
@@ -45,9 +43,3 @@ class OrganizationGroups extends React.PureComponent {
);
}
}
-
-const mapStateToProps = (state, ownProps) => ({
- organization: getOrganizationByKey(state, ownProps.params.organizationKey)
-});
-
-export default connect(mapStateToProps)(OrganizationGroups);
diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPermissionTemplates.js b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPermissionTemplates.js
deleted file mode 100644
index 201c72151be..00000000000
--- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPermissionTemplates.js
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-// @flow
-import React from 'react';
-import { connect } from 'react-redux';
-import AppContainer from '../../permission-templates/components/AppContainer';
-import { getOrganizationByKey } from '../../../store/rootReducer';
-/*:: import type { Organization } from '../../../store/organizations/duck'; */
-
-/*::
-type Props = {
- location: {},
- organization: Organization
-};
-*/
-
-function OrganizationPermissionTemplates(props /*: Props */) {
- return <AppContainer location={props.location} organization={props.organization} />;
-}
-
-const mapStateToProps = (state, ownProps) => ({
- organization: getOrganizationByKey(state, ownProps.params.organizationKey)
-});
-
-export default connect(mapStateToProps)(OrganizationPermissionTemplates);
diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPermissions.tsx b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPermissions.tsx
deleted file mode 100644
index b2136ea2f35..00000000000
--- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPermissions.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import * as React from 'react';
-import { connect } from 'react-redux';
-import GlobalPermissionsApp from '../../permissions/global/components/App';
-import { getOrganizationByKey } from '../../../store/rootReducer';
-import { Organization } from '../../../app/types';
-
-interface Props {
- organization: Organization;
-}
-
-function OrganizationPermissions({ organization }: Props) {
- return <GlobalPermissionsApp organization={organization} />;
-}
-
-const mapStateToProps = (state: any, ownProps: any) => ({
- organization: getOrganizationByKey(state, ownProps.params.organizationKey)
-});
-
-export default connect(mapStateToProps)(OrganizationPermissions);
diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationProjectsManagement.js b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationProjectsManagement.js
deleted file mode 100644
index a8ae5dd4b09..00000000000
--- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationProjectsManagement.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-// @flow
-import React from 'react';
-import { connect } from 'react-redux';
-import AppContainer from '../../projectsManagement/AppContainer';
-import { getOrganizationByKey } from '../../../store/rootReducer';
-/*:: import type { Organization } from '../../../store/organizations/duck'; */
-
-/*::
-type Props = {
- organization: Organization
-};
-*/
-
-function OrganizationProjectsManagement(props /*: Props */) {
- return <AppContainer organization={props.organization} />;
-}
-
-const mapStateToProps = (state, ownProps) => ({
- organization: getOrganizationByKey(state, ownProps.params.organizationKey)
-});
-
-export default connect(mapStateToProps)(OrganizationProjectsManagement);
diff --git a/server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationAdmin-test.js b/server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationAdmin-test.js
deleted file mode 100644
index 77c7e788dcf..00000000000
--- a/server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationAdmin-test.js
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import React from 'react';
-import { shallow } from 'enzyme';
-import { OrganizationAdmin } from '../OrganizationAdmin';
-
-jest.mock('../../../../app/utils/handleRequiredAuthorization', () => jest.fn());
-
-it('should render children', () => {
- const organization = { canAdmin: true };
- expect(
- shallow(
- <OrganizationAdmin organization={organization}>
- <div>hello</div>
- </OrganizationAdmin>
- )
- ).toMatchSnapshot();
-});
-
-it('should not render anything', () => {
- const organization = { canAdmin: false };
- expect(
- shallow(
- <OrganizationAdmin organization={organization}>
- <div>hello</div>
- </OrganizationAdmin>
- ).type()
- ).toBeNull();
-});
diff --git a/server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationAdminContainer-test.tsx b/server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationAdminContainer-test.tsx
new file mode 100644
index 00000000000..dc4eab48ac5
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationAdminContainer-test.tsx
@@ -0,0 +1,60 @@
+/*
+* SonarQube
+* Copyright (C) 2009-2017 SonarSource SA
+* mailto:info AT sonarsource DOT com
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this program; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+import * as React from 'react';
+import { shallow } from 'enzyme';
+import { Location } from 'history';
+import { OrganizationAdmin } from '../OrganizationAdminContainer';
+import { Visibility } from '../../../../app/types';
+
+jest.mock('../../../../app/utils/handleRequiredAuthorization', () => ({ default: jest.fn() }));
+
+const locationMock = {} as Location;
+
+it('should render children', () => {
+ const organization = {
+ canAdmin: true,
+ key: 'foo',
+ name: 'Foo',
+ projectVisibility: Visibility.Public
+ };
+ expect(
+ shallow(
+ <OrganizationAdmin organization={organization} location={locationMock}>
+ <div>hello</div>
+ </OrganizationAdmin>
+ )
+ ).toMatchSnapshot();
+});
+
+it('should not render anything', () => {
+ const organization = {
+ canAdmin: false,
+ key: 'foo',
+ name: 'Foo',
+ projectVisibility: Visibility.Public
+ };
+ expect(
+ shallow(
+ <OrganizationAdmin organization={organization} location={locationMock}>
+ <div>hello</div>
+ </OrganizationAdmin>
+ ).type()
+ ).toBeNull();
+});
diff --git a/server/sonar-web/src/main/js/apps/organizations/components/__tests__/__snapshots__/OrganizationAdmin-test.js.snap b/server/sonar-web/src/main/js/apps/organizations/components/__tests__/__snapshots__/OrganizationAdmin-test.js.snap
deleted file mode 100644
index 331cb8d84f7..00000000000
--- a/server/sonar-web/src/main/js/apps/organizations/components/__tests__/__snapshots__/OrganizationAdmin-test.js.snap
+++ /dev/null
@@ -1,7 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render children 1`] = `
-<div>
- hello
-</div>
-`;
diff --git a/server/sonar-web/src/main/js/apps/organizations/components/__tests__/__snapshots__/OrganizationAdminContainer-test.tsx.snap b/server/sonar-web/src/main/js/apps/organizations/components/__tests__/__snapshots__/OrganizationAdminContainer-test.tsx.snap
new file mode 100644
index 00000000000..349db2dd14c
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/organizations/components/__tests__/__snapshots__/OrganizationAdminContainer-test.tsx.snap
@@ -0,0 +1,17 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render children 1`] = `
+<div
+ location={Object {}}
+ organization={
+ Object {
+ "canAdmin": true,
+ "key": "foo",
+ "name": "Foo",
+ "projectVisibility": "public",
+ }
+ }
+>
+ hello
+</div>
+`;
diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigation-test.tsx.snap b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigation-test.tsx.snap
index 66184bbc5d4..b9efc8fe2e3 100644
--- a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigation-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigation-test.tsx.snap
@@ -18,6 +18,7 @@ exports[`admin 1`] = `
"canDelete": true,
"key": "foo",
"name": "Foo",
+ "projectVisibility": "public",
}
}
/>
@@ -221,6 +222,7 @@ exports[`regular user 1`] = `
"canDelete": false,
"key": "foo",
"name": "Foo",
+ "projectVisibility": "public",
}
}
/>
@@ -344,6 +346,7 @@ exports[`undeletable org 1`] = `
"canDelete": false,
"key": "foo",
"name": "Foo",
+ "projectVisibility": "public",
}
}
/>
diff --git a/server/sonar-web/src/main/js/apps/organizations/routes.js b/server/sonar-web/src/main/js/apps/organizations/routes.ts
index d4cbdaa8a9c..fff5e339798 100644
--- a/server/sonar-web/src/main/js/apps/organizations/routes.js
+++ b/server/sonar-web/src/main/js/apps/organizations/routes.ts
@@ -17,19 +17,20 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import { RouterState, RedirectFunction } from 'react-router';
+import GlobalPermissionsApp from '../permissions/global/components/App';
import OrganizationPageContainer from './components/OrganizationPage';
import OrganizationPageExtension from '../../app/components/extensions/OrganizationPageExtension';
import OrganizationContainer from './components/OrganizationContainer';
import OrganizationProjects from './components/OrganizationProjects';
import OrganizationRules from './components/OrganizationRules';
-import OrganizationAdminContainer from './components/OrganizationAdmin';
+import OrganizationAdminContainer from './components/OrganizationAdminContainer';
import OrganizationEdit from './components/OrganizationEdit';
import OrganizationGroups from './components/OrganizationGroups';
import OrganizationMembersContainer from './components/OrganizationMembersContainer';
-import OrganizationPermissions from './components/OrganizationPermissions';
-import OrganizationPermissionTemplates from './components/OrganizationPermissionTemplates';
-import OrganizationProjectsManagement from './components/OrganizationProjectsManagement';
import OrganizationDelete from './components/OrganizationDelete';
+import PermissionTemplateApp from '../permission-templates/components/AppContainer';
+import ProjectManagementApp from '../projectsManagement/AppContainer';
import qualityGatesRoutes from '../quality-gates/routes';
import qualityProfilesRoutes from '../quality-profiles/routes';
import Issues from '../issues/components/AppContainer';
@@ -41,7 +42,7 @@ const routes = [
childRoutes: [
{
indexRoute: {
- onEnter(nextState, replace) {
+ onEnter(nextState: RouterState, replace: RedirectFunction) {
const { params } = nextState;
replace(`/organizations/${params.organizationKey}/projects`);
}
@@ -84,9 +85,9 @@ const routes = [
{ path: 'delete', component: OrganizationDelete },
{ path: 'edit', component: OrganizationEdit },
{ path: 'groups', component: OrganizationGroups },
- { path: 'permissions', component: OrganizationPermissions },
- { path: 'permission_templates', component: OrganizationPermissionTemplates },
- { path: 'projects_management', component: OrganizationProjectsManagement }
+ { path: 'permissions', component: GlobalPermissionsApp },
+ { path: 'permission_templates', component: PermissionTemplateApp },
+ { path: 'projects_management', component: ProjectManagementApp }
]
}
]
diff --git a/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.tsx b/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.tsx
index 913058f2e88..05730e8252e 100644
--- a/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.tsx
+++ b/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.tsx
@@ -69,9 +69,8 @@ export default class AllHoldersList extends React.PureComponent<Props> {
};
render() {
- const order = PERMISSIONS_ORDER;
const l10nPrefix = this.props.organization ? 'organizations_permissions' : 'global_permissions';
- const permissions = order.map(p => ({
+ const permissions = PERMISSIONS_ORDER.map(p => ({
key: p,
name: translate(l10nPrefix, p),
description: translate(l10nPrefix, p, 'desc')
diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx
index 96d9e40d1c2..390fa00a8d8 100644
--- a/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx
+++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx
@@ -35,10 +35,6 @@ interface Props {
}
export default class PermissionHeader extends React.PureComponent<Props> {
- static defaultProps = {
- showPublicProjectsWarning: false
- };
-
handlePermissionClick = (event: React.SyntheticEvent<HTMLAnchorElement>) => {
event.preventDefault();
event.currentTarget.blur();