From 40e9fbebb89ebfa506c0136d72586d2a25384a40 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Thu, 21 Mar 2019 14:36:51 +0530 Subject: [PATCH 01/28] Created Component for Sub Routes --- .../src/components/RouteWithSubRoutes.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/RouteWithSubRoutes.js 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..d4c5505599 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/RouteWithSubRoutes.js @@ -0,0 +1,20 @@ +import React from 'react'; +import {Route} from 'react-router-dom'; +class RouteWithSubRoutes extends React.Component{ + props; + constructor(props){ + super(props); + console.log(props); + this.props = props; + } + render() { + return( + ( + + )}/> + ); + } + +} + +export default RouteWithSubRoutes; \ No newline at end of file From 7ee7384969ca0f5cf4918785251986cd3145ef4b Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Thu, 21 Mar 2019 19:59:40 +0530 Subject: [PATCH 02/28] Changed webpack to absolute path --- .../react-app/webpack.config.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/webpack.config.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/webpack.config.js index dcb16b0f5e..c1724e9a8c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/webpack.config.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/webpack.config.js @@ -21,6 +21,9 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const config = { devtool: "source-map", + output: { + publicPath: '/publisher/' // <---- this + }, watch: false, resolve: { alias: { From 15f38ba101f4eea135bc8cf9df3fc0884f561fd8 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Thu, 21 Mar 2019 20:00:41 +0530 Subject: [PATCH 03/28] Added login to router --- .../react-app/src/App.js | 26 +++- .../react-app/src/index.js | 130 ++++++++++++++---- 2 files changed, 125 insertions(+), 31 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 5cf9be115e..f09d174c33 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,31 @@ 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)} -
+ +
+
    +
  • Tacos
  • +
  • Sandwiches
  • +
+ + {this.routes.map((route) => ( + + ))} +
+
); } 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..2478ce8287 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,123 @@ -import React from 'react'; +// import React from 'react'; import ReactDOM from 'react-dom'; -import './index.css'; -import App from './App'; +// import './index.css'; import * as serviceWorker from './serviceWorker'; -import { renderRoutes } from "react-router-config"; -import Dashboard from "./pages/dashboard/Dashboard" -import Login from "./pages/Login"; -import {BrowserRouter} from "react-router-dom"; +// import { renderRoutes } from "react-router-config"; +// 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 +// } +// ] +// } +// ]; +// +// ReactDOM.render( +// {/* kick it all off with the root route */} +// {renderRoutes(routes)} +// , 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. +// // Learn more about service workers: https://bit.ly/CRA-PWA +// serviceWorker.unregister(); + + +import React from 'react'; +import { + BrowserRouter as Router, + Route, + Link, +} from 'react-router-dom'; +import RouteWithSubRoutes from "./components/RouteWithSubRoutes" +import App from "./App" +import Login from "./pages/Login" + +const Sandwiches = () =>

Sandwiches

+ +const Tacos = ({ routes }) => ( +
+

Tacos

+
    +
  • Bus
  • +
  • Cart
  • +
+ {routes.map((route) => ( + + ))} +
+) + +const Bus = () =>

Bus

+const Cart = () =>

Cart

const routes = [ { - component: App, + path: '/publisher/Login', + component: Login + }, + { + path: '/publisher/tacos', + component: Tacos, routes: [ { - path: "/publisher", - exact: true, - component: Dashboard, - routes: [ - { - path: "/publisher/a", - component: Login - } - ] + path: '/publisher/tacos/bus', + component: Login }, { - path: "/publisher/login", - component: Login + path: '/publisher/tacos/cart', + component: Cart } ] } -]; +] + +// const RouteWithSubRoutes = (route) => ( +// ( +// +// )}/> +// ) + +// class App extends React.Component { +// render() { +// return ( +// +//
+//
    +//
  • Tacos
  • +//
  • Sandwiches
  • +//
+// +// {routes.map((route) => ( +// +// ))} +//
+//
+// ) +// } +// } -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. From 536a2ca81b5ccd45cec7cd9d23ce8608af0b65ab Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Tue, 26 Mar 2019 22:40:07 +0530 Subject: [PATCH 04/28] Created new routes with router config --- .../react-app/src/App.js | 5 - .../src/components/RouteWithSubRoutes.js | 1 - .../react-app/src/index.js | 100 ++---------------- 3 files changed, 7 insertions(+), 99 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 f09d174c33..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 @@ -16,11 +16,6 @@ class App extends React.Component { return (
-
    -
  • Tacos
  • -
  • Sandwiches
  • -
- {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 index d4c5505599..c172b28edd 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 @@ -4,7 +4,6 @@ class RouteWithSubRoutes extends React.Component{ props; constructor(props){ super(props); - console.log(props); this.props = props; } render() { 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 2478ce8287..2a393bdfbc 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,75 +1,12 @@ -// import React from 'react'; +import React from 'react'; import ReactDOM from 'react-dom'; -// import './index.css'; +import './index.css'; import * as serviceWorker from './serviceWorker'; -// import { renderRoutes } from "react-router-config"; -// 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 -// } -// ] -// } -// ]; -// -// ReactDOM.render( -// {/* kick it all off with the root route */} -// {renderRoutes(routes)} -// , 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. -// // Learn more about service workers: https://bit.ly/CRA-PWA -// serviceWorker.unregister(); - - -import React from 'react'; -import { - BrowserRouter as Router, - Route, - Link, -} from 'react-router-dom'; -import RouteWithSubRoutes from "./components/RouteWithSubRoutes" import App from "./App" import Login from "./pages/Login" +import Dashboard from "./pages/dashboard/Dashboard" -const Sandwiches = () =>

Sandwiches

- -const Tacos = ({ routes }) => ( -
-

Tacos

-
    -
  • Bus
  • -
  • Cart
  • -
- - {routes.map((route) => ( - - ))} -
-) -const Bus = () =>

Bus

-const Cart = () =>

Cart

const routes = [ { @@ -77,12 +14,12 @@ const routes = [ component: Login }, { - path: '/publisher/tacos', - component: Tacos, + path: '/publisher/dashboard', + component: Dashboard, routes: [ { - path: '/publisher/tacos/bus', - component: Login + path: '/publisher/dashboard/bus', + component: Bus }, { path: '/publisher/tacos/cart', @@ -92,30 +29,7 @@ const routes = [ } ] -// const RouteWithSubRoutes = (route) => ( -// ( -// -// )}/> -// ) -// class App extends React.Component { -// render() { -// return ( -// -//
-//
    -//
  • Tacos
  • -//
  • Sandwiches
  • -//
-// -// {routes.map((route) => ( -// -// ))} -//
-//
-// ) -// } -// } ReactDOM.render( , document.getElementById('root')); From ab4b5d17649930c0dddd6f0b4b237d722c105b4e Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Tue, 26 Mar 2019 22:40:28 +0530 Subject: [PATCH 05/28] Created Layout for dashboard --- .../src/pages/dashboard/Dashboard.js | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) 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) => ( + + ))} +