Browse Source

Navbar & CoinDownModal prop refactor

all-modes
Miika Turunen 8 years ago
parent
commit
219bd18a3a
  1. 30
      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

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

@ -1,12 +1,13 @@
import React from 'react'; import React from 'react';
import { connect } from 'react-redux';
import { toggleCoindDownModal } from '../../../actions/actionCreators'; import { toggleCoindDownModal } from '../../../actions/actionCreators';
import Store from '../../../store'; import Store from '../../../store';
import CoindDownModalRender from './coindDownModal.render'; import CoindDownModalRender from './coindDownModal.render';
class CoindDownModal extends React.Component { class CoindDownModal extends React.Component {
constructor(props) { constructor() {
super(props); super();
this.state = { this.state = {
display: false, display: false,
debugLogCrash: null, debugLogCrash: null,
@ -18,20 +19,12 @@ class CoindDownModal extends React.Component {
Store.dispatch(toggleCoindDownModal(false)); Store.dispatch(toggleCoindDownModal(false));
} }
componentWillReceiveProps(props) { componentWillReceiveProps(nextProps) {
const coindDownModalProps = props ? props.Dashboard : null; console.log(nextProps.displayCoindDownModal);
if (this.props.displayCoindDownModal !== nextProps.displayCoindDownModal) {
if (coindDownModalProps &&
coindDownModalProps.displayCoindDownModal !== this.state.display) {
this.setState(Object.assign({}, this.state, {
display: coindDownModalProps.displayCoindDownModal,
}));
setTimeout(() => {
this.setState(Object.assign({}, this.state, { this.setState(Object.assign({}, this.state, {
display: coindDownModalProps.displayCoindDownModal, display: nextProps.displayCoindDownModal,
})); }));
}, 100);
} }
} }
@ -43,5 +36,12 @@ class CoindDownModal extends React.Component {
return null; return null;
} }
} }
const mapStateToProps = (state) => {
return {
displayCoindDownModal: state.Dashboard.displayCoindDownModal,
debugLog: state.Settings.debugLog
};
};
export default CoindDownModal; 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> <strong>Debug.log (last 50 lines)</strong>
<div className="form-group form-material floating"> <div className="form-group form-material floating">
<textarea <textarea
readOnly
className="form-control" className="form-control"
value={ this.props.Settings.debugLog }></textarea> value={ this.props.debugLog || '' }></textarea>
</div> </div>
<button <button
type="button" type="button"

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

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

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

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import { connect } from 'react-redux';
import { import {
dashboardChangeSection, dashboardChangeSection,
toggleAddcoinModal, toggleAddcoinModal,
@ -14,8 +15,8 @@ import Config from '../../../config';
import NavbarRender from './navbar.render'; import NavbarRender from './navbar.render';
class Navbar extends React.Component { class Navbar extends React.Component {
constructor(props) { constructor() {
super(props); super();
this.state = { this.state = {
openDropMenu: false, openDropMenu: false,
nativeOnly: Config.iguanaLessMode, nativeOnly: Config.iguanaLessMode,
@ -108,5 +109,18 @@ class Navbar extends React.Component {
return NavbarRender.call(this); 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