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 8325bbc957..5786ced341 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 @@ -56,16 +56,11 @@ if (theme.current === "default") { * */ class Base extends Component { - constructor() { - super(); - this.state = {}; - } render() { - this.setState(); return (
- + @@ -73,16 +68,12 @@ class Base extends Component {
) } - - setState() { - if (this.props.location.state){ - this.state = this.props.location.state; - } else { - this.state = {}; - } - } } +Base.propTypes = { + updateState: React.PropTypes.func.isRequired +}; + /** * This component is referred by the index.js to initiate the application. * TODO: Currently the URL shows like https://localhost:9443/publisher/#/publisher/assets/apps/create. this needs to @@ -93,6 +84,11 @@ class Store extends Component { constructor() { super(); + if (!this.state) { + this.state = {}; + this.state.store = {}; + } + this.updateState = this.updateState.bind(this); } render() { @@ -101,15 +97,22 @@ class Store extends Component { - - - + }/> + }/> + }/> ); } + + updateState(data) { + this.setState(data); + } } export default Store; 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 d446c7556d..acaab4d88d 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 @@ -26,7 +26,7 @@ import {List, ListItem} from 'material-ui/List'; import Apps from 'material-ui/svg-icons/navigation/apps'; import NotificationsIcon from 'material-ui/svg-icons/social/notifications'; import ActionAccountCircle from 'material-ui/svg-icons/action/account-circle'; -import { Link } from 'react-router-dom'; +import {Link, withRouter} from 'react-router-dom'; /** * Base Layout: @@ -36,15 +36,6 @@ import { Link } from 'react-router-dom'; * */ class BaseLayout extends Component { - constructor(props) { - super(props); - this.state = this.props.state; - } - - componentWillMount() { - - } - handleApplicationClick() { this.handleHistory('/assets/apps'); } @@ -59,9 +50,9 @@ class BaseLayout extends Component { } handleUserLogin() { - if (this.state.user) { + if (this.props.state.store.user) { return ( - + ); @@ -73,10 +64,10 @@ class BaseLayout extends Component { } handleNotification() { - if (this.state.user) { + if (this.props.state.store.user) { return ( @@ -134,11 +125,8 @@ class BaseLayout extends Component { } -BaseLayout - .propTypes = { +BaseLayout.propTypes = { children: PropTypes.element }; -export -default -BaseLayout; +export default withRouter(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 31d3404d39..f7938349a8 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 @@ -61,14 +61,18 @@ class Login extends Component { handleLogin(event) { event.preventDefault(); + console.log(this.props); //TODO: send authentication request. let location = { - pathname: this.state.referrer, - state: { - notifications: 0, - user: this.state.userName + pathname: this.state.referrer + }; + let storeState = { + store : { + user: this.state.userName, + notifications: 0 } }; + this.props.updateState(storeState); this.props.history.push(location); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/themes/custom-theme.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/components/index.js similarity index 58% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/themes/custom-theme.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/components/index.js index f8cfdff1bf..de55ff9eed 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/themes/custom-theme.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/components/index.js @@ -16,24 +16,10 @@ * under the License. */ + +import BaseLayout from './BaseLayout'; /** - * This a sample custom theme file. In config.json, if the following changes are done, this theme will be applied. - * { - * "theme" : { - * "type" : "custom", - * "value" : "custom-theme" - * } - * } + * Contains all UI components related to Application, Login and Platform */ -import { - indigo500, indigo700, redA200, -} from 'material-ui/styles/colors'; -export default { - palette: { - primary1Color: indigo500, - primary2Color: indigo700, - accent1Color: redA200, - pickerHeaderColor: indigo500, - }, -}; +export default {BaseLayout};