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 5cf9be115e..be1c130124 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 @@ -1,19 +1,26 @@ import React from "react"; import "antd/dist/antd.css"; -import { renderRoutes } from "react-router-config"; +import RouteWithSubRoutes from "./components/RouteWithSubRoutes"; +import { + BrowserRouter as Router, + Link, +} from 'react-router-dom'; class App extends React.Component { + routes; constructor(props) { super(props); - this.state = { - route : props.route - } + this.routes = props.routes; } render() { return ( -
- {renderRoutes(this.state.route.routes)} -
+ +
+ {this.routes.map((route) => ( + + ))} +
+
); } 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 new file mode 100644 index 0000000000..c172b28edd --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/RouteWithSubRoutes.js @@ -0,0 +1,19 @@ +import React from 'react'; +import {Route} from 'react-router-dom'; +class RouteWithSubRoutes extends React.Component{ + props; + constructor(props){ + super(props); + this.props = props; + } + render() { + return( + ( + + )}/> + ); + } + +} + +export default RouteWithSubRoutes; \ No newline at end of file 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 96931fc788..7ccba02f0c 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 @@ -1,41 +1,27 @@ import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; -import App from './App'; import * as serviceWorker from './serviceWorker'; -import { renderRoutes } from "react-router-config"; +import App from "./App" +import Login from "./pages/Login" import Dashboard from "./pages/dashboard/Dashboard" -import Login from "./pages/Login"; -import {BrowserRouter} from "react-router-dom"; + const routes = [ { - component: App, - routes: [ - { - path: "/publisher", - exact: true, - component: Dashboard, - routes: [ - { - path: "/publisher/a", - component: Login - } - ] - }, - { - path: "/publisher/login", - component: Login - } - ] + path: '/publisher/Login', + component: Login + }, + { + path: '/publisher/dashboard', + component: Dashboard } -]; +] + + -ReactDOM.render( - {/* kick it all off with the root route */} - {renderRoutes(routes)} -, document.getElementById('root')); +ReactDOM.render( , document.getElementById('root')); // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. 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 6088af4b6f..cca9ef97b5 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 @@ -1,5 +1,5 @@ import React from "react"; -import { Layout, Menu, Breadcrumb } from 'antd'; +import { Layout, Menu, Breadcrumb, PageHeader } from 'antd'; const { Header, Content, Footer } = Layout; @@ -8,15 +8,15 @@ import Logo from "../../../public/images/logo.svg"; import Login from "../Login"; import {renderRoutes} from "react-router-config"; import {NavLink} from "react-router-dom"; +import RouteWithSubRoutes from "../../components/RouteWithSubRoutes" class Dashboard extends React.Component { constructor(props) { super(props); this.state = { - route : props.route + routes : props.routes } - console.log(props); } render() { @@ -35,19 +35,20 @@ class Dashboard extends React.Component { nav 3 - - + + Home List App - - Items - - - {/* child routes won't render without this */} - {renderRoutes(this.state.route.routes, { someProp: "these extra props are optional" })} -
Content
+ +
+ {this.state.routes.map((route) => ( + + ))} +