diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/App.jsx b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/App.jsx index b953a199c0..336b85a7bd 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/App.jsx +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/App.jsx @@ -55,18 +55,18 @@ if (theme.current === "default") { * not want to serve the URL. * */ class Base extends Component { + constructor() { super(); - this.state = { - user: "admin" - } + this.state = {}; } render() { + this.setState(); if (this.state.user) { return (
- + @@ -76,6 +76,14 @@ class Base extends Component { } return () } + + setState() { + if (this.props.location.state){ + this.state = this.props.location.state; + } else { + this.state = {}; + } + } } /** @@ -85,17 +93,22 @@ class Base extends Component { * * */ class Store extends Component { + + constructor() { + super(); + } + render() { return (
- - - - - - - + + + + + + +
); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/components/BaseLayout.jsx b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/components/BaseLayout.jsx index 2e9c2f8c17..fea7f5e03b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/components/BaseLayout.jsx +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/components/BaseLayout.jsx @@ -30,6 +30,7 @@ import Feedback from 'material-ui/svg-icons/action/feedback'; import DevicesOther from 'material-ui/svg-icons/hardware/devices-other'; import NotificationsIcon from 'material-ui/svg-icons/social/notifications'; import ActionAccountCircle from 'material-ui/svg-icons/action/account-circle'; +import FlatButton from 'material-ui/FlatButton'; /** * Base Layout: @@ -39,12 +40,9 @@ import ActionAccountCircle from 'material-ui/svg-icons/action/account-circle'; * */ class BaseLayout extends Component { - constructor() { - super(); - this.state = { - notifications: 0, - user: 'Admin' - } + constructor(props) { + super(props); + this.state = this.props.state; } componentWillMount() { @@ -55,25 +53,6 @@ class BaseLayout extends Component { this.handleHistory('/assets/apps'); } - handleOverviewClick() { - this.handleHistory('/overview'); - } - - handleApplicationCreateClick() { - this.handleHistory('/assets/apps/create'); - } - - handlePlatformClick() { - this.handleHistory('/assets/platforms'); - } - - handlePlatformCreateClick() { - this.handleHistory('/assets/platforms/create'); - } - - handleReviewClick() { - this.handleHistory('/assets/reviews'); - } /** * The method to update the history. @@ -83,33 +62,51 @@ class BaseLayout extends Component { this.props.history.push(to); } + handleUserLogin() { + if (this.state.user) { + return ( + + + + ); + } else { + return ( + + ); + } + } + + handleNotification() { + if (this.state.user) { + return ( + + + + + + ); + } + } + render() { return (
- - - - - - - { - console.log("Clicked") - }}> - - + {this.handleNotification()} + {this.handleUserLogin()}
} />
- + - } initiallyOpen={false} primaryTogglesNestedList={true} @@ -117,27 +114,10 @@ class BaseLayout extends Component { nestedItems={[ } - />]} - /> - } - initiallyOpen={false} - primaryTogglesNestedList={true} - onClick={this.handlePlatformClick.bind(this)} - nestedItems={[ - } + primaryText="Business" //TODO: categoryies ... + leftIcon={} />]} /> - }/>
@@ -158,8 +138,11 @@ class BaseLayout extends Component { } -BaseLayout.propTypes = { +BaseLayout + .propTypes = { children: PropTypes.element }; -export default BaseLayout; +export +default +BaseLayout; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/components/Login.jsx b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/components/Login.jsx index 72255be8dd..31d3404d39 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/components/Login.jsx +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/components/Login.jsx @@ -19,10 +19,12 @@ import qs from 'qs'; import React, {Component} from 'react'; import Checkbox from 'material-ui/Checkbox'; -import {Redirect, Switch} from 'react-router-dom'; +import {Redirect, Route} from 'react-router-dom'; import RaisedButton from 'material-ui/RaisedButton'; import {Card, CardActions, CardTitle} from 'material-ui/Card'; import {TextValidator, ValidatorForm} from 'react-material-ui-form-validator'; +import Store from '../App'; + //todo: remove the {TextValidator, ValidatorForm} and implement it manually. @@ -39,10 +41,9 @@ class Login extends Component { constructor() { super(); this.state = { - isLoggedIn: true, + isLoggedIn: false, referrer: "/", userName: "", - password: "", rememberMe: true } } @@ -60,6 +61,15 @@ class Login extends Component { handleLogin(event) { event.preventDefault(); + //TODO: send authentication request. + let location = { + pathname: this.state.referrer, + state: { + notifications: 0, + user: this.state.userName + } + }; + this.props.history.push(location); } /** @@ -95,16 +105,21 @@ class Login extends Component { ); } - render() { + handleSuccessfulLogin() { + return ( + + ); + } - if (!this.state.isLoggedIn) { + render() { + if (!(this.state.isLoggedIn && this.state.userName)) { return (
{/*TODO: Style the components.*/} - +
); } else { - return ( - - - - ); + this.handleSuccessfulLogin(); } } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/index.js index 6c459661b6..12795d528e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/index.js @@ -5,5 +5,4 @@ import './index.css'; ReactDOM.render(, document.getElementById('root')); -console.log('Hello World!');