Browse Source

Navbar & CoinDownModal prop refactor

all-modes
Miika Turunen 8 years ago
parent
commit
219bd18a3a
  1. 32
      react/src/components/dashboard/coindDownModal/coindDownModal.js
  2. 3
      react/src/components/dashboard/coindDownModal/coindDownModal.render.js
  3. 4
      react/src/components/dashboard/main/dashboard.render.js
  4. 20
      react/src/components/dashboard/navbar/navbar.js

32
react/src/components/dashboard/coindDownModal/coindDownModal.js

@ -1,12 +1,13 @@
import React from 'react';
import { connect } from 'react-redux';
import { toggleCoindDownModal } from '../../../actions/actionCreators';
import Store from '../../../store';
import CoindDownModalRender from './coindDownModal.render';
class CoindDownModal extends React.Component {
constructor(props) {
super(props);
constructor() {
super();
this.state = {
display: false,
debugLogCrash: null,
@ -18,20 +19,12 @@ class CoindDownModal extends React.Component {
Store.dispatch(toggleCoindDownModal(false));
}
componentWillReceiveProps(props) {
const coindDownModalProps = props ? props.Dashboard : null;
if (coindDownModalProps &&
coindDownModalProps.displayCoindDownModal !== this.state.display) {
componentWillReceiveProps(nextProps) {
console.log(nextProps.displayCoindDownModal);
if (this.props.displayCoindDownModal !== nextProps.displayCoindDownModal) {
this.setState(Object.assign({}, this.state, {
display: coindDownModalProps.displayCoindDownModal,
display: nextProps.displayCoindDownModal,
}));
setTimeout(() => {
this.setState(Object.assign({}, this.state, {
display: coindDownModalProps.displayCoindDownModal,
}));
}, 100);
}
}
@ -43,5 +36,12 @@ class CoindDownModal extends React.Component {
return null;
}
}
export default CoindDownModal;
const mapStateToProps = (state) => {
return {
displayCoindDownModal: state.Dashboard.displayCoindDownModal,
debugLog: state.Settings.debugLog
};
};
export default connect(mapStateToProps)(CoindDownModal);

3
react/src/components/dashboard/coindDownModal/coindDownModal.render.js

@ -24,8 +24,9 @@ const CoindDownModalRender = function () {
<strong>Debug.log (last 50 lines)</strong>
<div className="form-group form-material floating">
<textarea
readOnly
className="form-control"
value={ this.props.Settings.debugLog }></textarea>
value={ this.props.debugLog || '' }></textarea>
</div>
<button
type="button"

4
react/src/components/dashboard/main/dashboard.render.js

@ -23,8 +23,8 @@ const DashboardRender = function() {
<div
className={ this.isSectionActive('wallets') ? 'page-main' : '' }
id="section-dashboard">
<Navbar {...this.props} />
<CoindDownModal {...this.props} />
<Navbar />
<CoindDownModal />
<div className={ this.isSectionActive('wallets') ? 'show' : 'hide' }>
<CoinTile {...this.props} />
<WalletsNav />

20
react/src/components/dashboard/navbar/navbar.js

@ -1,4 +1,5 @@
import React from 'react';
import { connect } from 'react-redux';
import {
dashboardChangeSection,
toggleAddcoinModal,
@ -14,8 +15,8 @@ import Config from '../../../config';
import NavbarRender from './navbar.render';
class Navbar extends React.Component {
constructor(props) {
super(props);
constructor() {
super();
this.state = {
openDropMenu: false,
nativeOnly: Config.iguanaLessMode,
@ -108,5 +109,18 @@ class Navbar extends React.Component {
return NavbarRender.call(this);
}
}
const mapStateToProps = (state) => {
return {
Dashboard: {
activeSection: state.Dashboard.activeSection,
},
Interval: {
interval: state.Interval.interval,
},
nativeOnly: Config.iguanaLessMode
};
};
export default connect(mapStateToProps)(Navbar);
export default Navbar;

Loading…
Cancel
Save