mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Updating to have the parent state only.
This commit is contained in:
parent
d04777a1e6
commit
2f726c674d
@ -56,16 +56,11 @@ if (theme.current === "default") {
|
|||||||
* */
|
* */
|
||||||
class Base extends Component {
|
class Base extends Component {
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
this.setState();
|
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<BaseLayout state={this.state}>
|
<BaseLayout state={this.props.state} updateState={this.props.updateState}>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route component={NotFound}/>
|
<Route component={NotFound}/>
|
||||||
</Switch>
|
</Switch>
|
||||||
@ -73,15 +68,11 @@ class Base extends Component {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setState() {
|
Base.propTypes = {
|
||||||
if (this.props.location.state){
|
updateState: React.PropTypes.func.isRequired
|
||||||
this.state = this.props.location.state;
|
};
|
||||||
} else {
|
|
||||||
this.state = {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component is referred by the index.js to initiate the application.
|
* This component is referred by the index.js to initiate the application.
|
||||||
@ -93,6 +84,11 @@ class Store extends Component {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
if (!this.state) {
|
||||||
|
this.state = {};
|
||||||
|
this.state.store = {};
|
||||||
|
}
|
||||||
|
this.updateState = this.updateState.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -101,15 +97,22 @@ class Store extends Component {
|
|||||||
<MuiThemeProvider muiTheme={muiTheme}>
|
<MuiThemeProvider muiTheme={muiTheme}>
|
||||||
<Router basename="store" history={history}>
|
<Router basename="store" history={history}>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/login" component={Login}/>
|
<Route path="/login"
|
||||||
<Route path="/logout" component={Login}/>
|
render={routeProps => <Login {...routeProps} updateState={this.updateState} state={this.state}/>}/>
|
||||||
<Route component={Base}/>
|
<Route path="/logout"
|
||||||
|
render={routeProps => <Base {...routeProps} updateState={this.updateState} state={this.state}/>}/>
|
||||||
|
<Route
|
||||||
|
render={routeProps => <Base {...routeProps} updateState={this.updateState} state={this.state}/>}/>
|
||||||
</Switch>
|
</Switch>
|
||||||
</Router>
|
</Router>
|
||||||
</MuiThemeProvider>
|
</MuiThemeProvider>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateState(data) {
|
||||||
|
this.setState(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Store;
|
export default Store;
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import {List, ListItem} from 'material-ui/List';
|
|||||||
import Apps from 'material-ui/svg-icons/navigation/apps';
|
import Apps from 'material-ui/svg-icons/navigation/apps';
|
||||||
import NotificationsIcon from 'material-ui/svg-icons/social/notifications';
|
import NotificationsIcon from 'material-ui/svg-icons/social/notifications';
|
||||||
import ActionAccountCircle from 'material-ui/svg-icons/action/account-circle';
|
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:
|
* Base Layout:
|
||||||
@ -36,15 +36,6 @@ import { Link } from 'react-router-dom';
|
|||||||
* */
|
* */
|
||||||
class BaseLayout extends Component {
|
class BaseLayout extends Component {
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = this.props.state;
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillMount() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
handleApplicationClick() {
|
handleApplicationClick() {
|
||||||
this.handleHistory('/assets/apps');
|
this.handleHistory('/assets/apps');
|
||||||
}
|
}
|
||||||
@ -59,9 +50,9 @@ class BaseLayout extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleUserLogin() {
|
handleUserLogin() {
|
||||||
if (this.state.user) {
|
if (this.props.state.store.user) {
|
||||||
return (
|
return (
|
||||||
<IconButton tooltip={this.state.user}>
|
<IconButton tooltip={this.props.state.store.user}>
|
||||||
<ActionAccountCircle/>
|
<ActionAccountCircle/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
@ -73,10 +64,10 @@ class BaseLayout extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleNotification() {
|
handleNotification() {
|
||||||
if (this.state.user) {
|
if (this.props.state.store.user) {
|
||||||
return (
|
return (
|
||||||
<Badge
|
<Badge
|
||||||
badgeContent={this.state.notifications}
|
badgeContent={this.props.state.store.notifications}
|
||||||
secondary={true}
|
secondary={true}
|
||||||
badgeStyle={{top: 12, right: 12}}>
|
badgeStyle={{top: 12, right: 12}}>
|
||||||
<IconButton tooltip="Notifications">
|
<IconButton tooltip="Notifications">
|
||||||
@ -134,11 +125,8 @@ class BaseLayout extends Component {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseLayout
|
BaseLayout.propTypes = {
|
||||||
.propTypes = {
|
|
||||||
children: PropTypes.element
|
children: PropTypes.element
|
||||||
};
|
};
|
||||||
|
|
||||||
export
|
export default withRouter(BaseLayout);
|
||||||
default
|
|
||||||
BaseLayout;
|
|
||||||
|
|||||||
@ -61,14 +61,18 @@ class Login extends Component {
|
|||||||
|
|
||||||
handleLogin(event) {
|
handleLogin(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
console.log(this.props);
|
||||||
//TODO: send authentication request.
|
//TODO: send authentication request.
|
||||||
let location = {
|
let location = {
|
||||||
pathname: this.state.referrer,
|
pathname: this.state.referrer
|
||||||
state: {
|
};
|
||||||
notifications: 0,
|
let storeState = {
|
||||||
user: this.state.userName
|
store : {
|
||||||
|
user: this.state.userName,
|
||||||
|
notifications: 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
this.props.updateState(storeState);
|
||||||
this.props.history.push(location);
|
this.props.history.push(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,24 +16,10 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* 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"
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
import {
|
|
||||||
indigo500, indigo700, redA200,
|
|
||||||
} from 'material-ui/styles/colors';
|
|
||||||
|
|
||||||
export default {
|
import BaseLayout from './BaseLayout';
|
||||||
palette: {
|
/**
|
||||||
primary1Color: indigo500,
|
* Contains all UI components related to Application, Login and Platform
|
||||||
primary2Color: indigo700,
|
*/
|
||||||
accent1Color: redA200,
|
|
||||||
pickerHeaderColor: indigo500,
|
export default {BaseLayout};
|
||||||
},
|
|
||||||
};
|
|
||||||
Loading…
Reference in New Issue
Block a user