Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix code issue #141

Merged
merged 5 commits into from
Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/javascript/app/Modules/Reports/Containers/reports.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import AppRoutes from 'Constants/routes';
import { localize } from '_common/localize';

class Reports extends React.Component {
state = { is_visible: false };

setWrapperRef = (node) => {
this.wrapper_ref = node;
};
Expand All @@ -28,11 +26,11 @@ class Reports extends React.Component {
localStorage.removeItem('layout-contract-replay');
this.props.showBlur();
document.addEventListener('mousedown', this.handleClickOutside);
this.setState({ is_visible: true });
this.props.toggleReports(true);
}

componentWillUnmount() {
this.setState({ is_visible: false });
this.props.toggleReports(false);
this.props.hideBlur();
document.removeEventListener('mousedown', this.handleClickOutside);
}
Expand All @@ -58,15 +56,15 @@ class Reports extends React.Component {
{
onClick: () => {
this.props.history.push(AppRoutes.trade);
this.setState({ is_visible: false });
this.props.toggleReports(false);
},
icon : IconClose,
title: localize('Close'),
},
];
return (
<FadeWrapper
is_visible={this.state.is_visible}
is_visible={this.props.is_visible}
className='reports-page-wrapper'
keyname='reports-page-wrapper'
>
Expand All @@ -88,16 +86,20 @@ class Reports extends React.Component {
}

Reports.propTypes = {
hideBlur: PropTypes.func,
history : PropTypes.object,
location: PropTypes.object,
routes : PropTypes.arrayOf(PropTypes.object),
showBlur: PropTypes.func,
hideBlur : PropTypes.func,
history : PropTypes.object,
is_visible : PropTypes.bool,
location : PropTypes.object,
routes : PropTypes.arrayOf(PropTypes.object),
showBlur : PropTypes.func,
toggleReports: PropTypes.func,
};

export default connect(
({ ui }) => ({
hideBlur: ui.hideRouteBlur,
showBlur: ui.showRouteBlur,
hideBlur : ui.hideRouteBlur,
is_visible : ui.is_reports_visible,
showBlur : ui.showRouteBlur,
toggleReports: ui.toggleReports,
})
)(withRouter(Reports));
7 changes: 7 additions & 0 deletions src/javascript/app/Stores/ui-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class UIStore extends BaseStore {
@observable is_main_drawer_on = false;
@observable is_notifications_drawer_on = false;
@observable is_positions_drawer_on = false;
@observable is_reports_visible = false;

@observable is_dark_mode_on = false;
@observable is_language_dialog_on = false;
Expand Down Expand Up @@ -81,6 +82,7 @@ export default class UIStore extends BaseStore {
'is_chart_layout_default',
'is_dark_mode_on',
'is_positions_drawer_on',
'is_reports_visible',
// 'is_purchase_confirm_on',
// 'is_purchase_lock_on',
];
Expand Down Expand Up @@ -232,6 +234,11 @@ export default class UIStore extends BaseStore {
this.is_positions_drawer_on = !this.is_positions_drawer_on;
}

@action.bound
toggleReports(is_visible) {
this.is_reports_visible = is_visible;
}

@action.bound
toggleServicesErrorModal(is_visible) {
this.is_services_error_visible = is_visible;
Expand Down