]> source.dussan.org Git - sonarqube.git/commitdiff
display 404 when accessing on-prem admin pages being in cloud mode
authorStas Vilchik <vilchiks@gmail.com>
Mon, 6 Feb 2017 09:55:12 +0000 (10:55 +0100)
committerStas Vilchik <stas-vilchik@users.noreply.github.com>
Tue, 7 Feb 2017 10:07:02 +0000 (11:07 +0100)
server/sonar-web/src/main/js/app/utils/startReactApp.js
server/sonar-web/src/main/js/apps/groups/routes.js
server/sonar-web/src/main/js/apps/organizations/forSingleOrganization.js [new file with mode: 0644]
server/sonar-web/src/main/js/apps/permission-templates/routes.js
server/sonar-web/src/main/js/apps/permissions/routes.js
server/sonar-web/src/main/js/apps/projects-admin/routes.js

index e28587b9184c035c32579ae2022c45273c76822f..32c8cb9a0fb664532c0c2e4522c5cc1e6c5d516f 100644 (file)
@@ -160,6 +160,7 @@ const startReactApp = () => {
                   </Route>
                 </Route>
 
+                <Route path="not_found" component={NotFound}/>
                 <Route path="*" component={NotFound}/>
               </Route>
             </Route>
index 08981267c7922aa233d0ff7604b7f36cc5267ce1..f221791c8561f053ee82e597971cbee7b0e35bc7 100644 (file)
@@ -20,7 +20,8 @@
 import React from 'react';
 import { IndexRoute } from 'react-router';
 import GroupsAppContainer from './components/GroupsAppContainer';
+import forSingleOrganization from '../organizations/forSingleOrganization';
 
 export default (
-    <IndexRoute component={GroupsAppContainer}/>
+    <IndexRoute component={forSingleOrganization(GroupsAppContainer)}/>
 );
diff --git a/server/sonar-web/src/main/js/apps/organizations/forSingleOrganization.js b/server/sonar-web/src/main/js/apps/organizations/forSingleOrganization.js
new file mode 100644 (file)
index 0000000..2a24742
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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 { withRouter } from 'react-router';
+import { areThereCustomOrganizations } from '../../store/rootReducer';
+
+const forSingleOrganization = (ComposedComponent: Object) => {
+  class X extends React.Component {
+    static displayName = `forSingleOrganization(${ComposedComponent.displayName})}`;
+
+    render () {
+      const { customOrganizations, router, ...other } = this.props;
+
+      if (customOrganizations) {
+        router.replace('/not_found');
+        return null;
+      }
+
+      return <ComposedComponent {...other}/>;
+    }
+  }
+
+  const mapStateToProps = state => ({
+    customOrganizations: areThereCustomOrganizations(state)
+  });
+
+  return connect(mapStateToProps)(withRouter(X));
+};
+
+export default forSingleOrganization;
index 799d82546f9e06a5e2eb07e6990dc12e00299685..3060d3331f03ed34363d7dd04ce1f60ab53d6a8a 100644 (file)
@@ -20,7 +20,8 @@
 import React from 'react';
 import { IndexRoute } from 'react-router';
 import AppContainer from './components/AppContainer';
+import forSingleOrganization from '../organizations/forSingleOrganization';
 
 export default (
-    <IndexRoute component={AppContainer}/>
+    <IndexRoute component={forSingleOrganization(AppContainer)}/>
 );
index a273a2914b63d4898302825e10296b1195fe47bf..ee80d1143a06915773021c8ca2397bf6df257bcf 100644 (file)
@@ -21,9 +21,10 @@ import React from 'react';
 import { IndexRoute } from 'react-router';
 import GlobalPermissionsApp from './global/components/App';
 import ProjectPermissionsApp from './project/components/App';
+import forSingleOrganization from '../organizations/forSingleOrganization';
 
 export const globalPermissionsRoutes = (
-    <IndexRoute component={GlobalPermissionsApp}/>
+    <IndexRoute component={forSingleOrganization(GlobalPermissionsApp)}/>
 );
 
 export const projectPermissionsRoutes = (
index 5b25254fb7f645e735ed213e3eda3fd5027dfd5c..f8442f2c5727cb2d3d5923380dccce2886ff6e6b 100644 (file)
@@ -20,7 +20,8 @@
 import React from 'react';
 import { IndexRoute } from 'react-router';
 import AppContainer from './AppContainer';
+import forSingleOrganization from '../organizations/forSingleOrganization';
 
-export default(
-    <IndexRoute component={AppContainer}/>
+export default (
+    <IndexRoute component={forSingleOrganization(AppContainer)}/>
 );