From 9a580e513f67a92c4b5c39762ab4373893a26fce Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Sun, 28 Apr 2019 17:22:16 +0530 Subject: [PATCH] fixed routing --- .../react-app/src/App.js | 30 +++++++++++-------- .../src/components/RouteWithSubRoutes.js | 2 +- .../react-app/src/index.js | 17 +++++++---- .../src/pages/dashboard/Dashboard.js | 2 +- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js index be1c130124..7ba8524e2e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js @@ -3,27 +3,33 @@ import "antd/dist/antd.css"; import RouteWithSubRoutes from "./components/RouteWithSubRoutes"; import { BrowserRouter as Router, - Link, + Link, Redirect, Switch, } from 'react-router-dom'; class App extends React.Component { routes; + constructor(props) { super(props); this.routes = props.routes; } - render() { - return ( - -
- {this.routes.map((route) => ( - - ))} -
-
- ); - } + render() { + console.log(this.routes); + return ( + +
+ + + {this.routes.map((route) => ( + + ))} + +
+
+ + ); + } } export default App; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/RouteWithSubRoutes.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/RouteWithSubRoutes.js index c172b28edd..41cb84caf8 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/RouteWithSubRoutes.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/RouteWithSubRoutes.js @@ -8,7 +8,7 @@ class RouteWithSubRoutes extends React.Component{ } render() { return( - ( + ( )}/> ); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js index df386140c4..046b3dae08 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js @@ -9,24 +9,29 @@ import AddNewApp from "./pages/dashboard/add-new-app/AddNewApp"; import './index.css'; import store from "./js/store/index"; import {Provider} from "react-redux"; +import {Switch} from "react-router"; const routes = [ { path: '/publisher/login', + exact: true, component: Login }, { - path: '/publisher', + path: '/publisher/dashboard', + exact: false, component: Dashboard, routes: [ { - path: '/publisher/apps', - component: Apps + path: '/publisher/dashboard/apps', + component: Apps, + exact: false }, { - path: '/publisher/new-app', - component: AddNewApp + path: '/publisher/dashboard/new-app', + component: AddNewApp, + exact: false } ] } @@ -35,7 +40,7 @@ const routes = [ ReactDOM.render( - + , document.getElementById('root')); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js index 9d8569b12a..0fca91e5a9 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js @@ -38,7 +38,7 @@ class Dashboard extends React.Component { - + {this.state.routes.map((route) => ( ))}