From 07167fcfca5fd9d558f9c0be743da8e51fa77098 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Mon, 17 Apr 2017 22:26:32 +0000 Subject: [PATCH 1/2] Fix dashboard edit button is disabled --- .../javascripts/components/ModalTrigger.jsx | 3 +++ .../dashboard/components/Controls.jsx | 20 ++++++++++--------- .../dashboard/components/SaveModal.jsx | 1 - superset/views/core.py | 7 +++---- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/superset/assets/javascripts/components/ModalTrigger.jsx b/superset/assets/javascripts/components/ModalTrigger.jsx index aee93ba826878..aaff97861b0a7 100644 --- a/superset/assets/javascripts/components/ModalTrigger.jsx +++ b/superset/assets/javascripts/components/ModalTrigger.jsx @@ -15,6 +15,7 @@ const propTypes = { bsSize: PropTypes.string, className: PropTypes.string, tooltip: PropTypes.string, + disabled: PropTypes.bool, }; const defaultProps = { @@ -24,6 +25,7 @@ const defaultProps = { isButton: false, bsSize: null, className: '', + disabled: false, }; export default class ModalTrigger extends React.Component { @@ -80,6 +82,7 @@ export default class ModalTrigger extends React.Component { className="modal-trigger" tooltip={this.props.tooltip} onClick={this.open} + disabled={this.props.disabled} > {this.props.triggerNode} {this.renderModal()} diff --git a/superset/assets/javascripts/dashboard/components/Controls.jsx b/superset/assets/javascripts/dashboard/components/Controls.jsx index 4248a6055f85b..75fe1bc0b53b4 100644 --- a/superset/assets/javascripts/dashboard/components/Controls.jsx +++ b/superset/assets/javascripts/dashboard/components/Controls.jsx @@ -43,7 +43,6 @@ class Controls extends React.PureComponent { } render() { const dashboard = this.props.dashboard; - const canSave = dashboard.dash_save_perm; const emailBody = `Checkout this dashboard: ${window.location.href}`; const emailLink = 'mailto:?Subject=Superset%20Dashboard%20' + `${dashboard.dashboard_title}&Body=${emailBody}`; @@ -81,26 +80,29 @@ class Controls extends React.PureComponent { onChange={this.changeCss.bind(this)} /> + + } /> - ); } diff --git a/superset/assets/javascripts/dashboard/components/SaveModal.jsx b/superset/assets/javascripts/dashboard/components/SaveModal.jsx index ade62bf6a47a7..88c8ad2089c05 100644 --- a/superset/assets/javascripts/dashboard/components/SaveModal.jsx +++ b/superset/assets/javascripts/dashboard/components/SaveModal.jsx @@ -107,7 +107,6 @@ class SaveModal extends React.PureComponent { { this.modal = modal; }} triggerNode={this.props.triggerNode} - isButton modalTitle="Save Dashboard" modalBody={ diff --git a/superset/views/core.py b/superset/views/core.py index 032d86155f219..8c442f0a393a3 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -1641,14 +1641,13 @@ def dashboard(**kwargs): # noqa dashboard_data = dash.data dashboard_data.update({ 'standalone_mode': request.args.get("standalone") == "true", + 'dash_save_perm': dash_save_perm, + 'dash_edit_perm': dash_edit_perm, }) bootstrap_data = { 'user_id': g.user.get_id(), - 'dash_save_perm': dash_save_perm, - 'dash_edit_perm': dash_edit_perm, - 'dash_edit_perm': check_ownership(dash, raise_if_false=False), - 'dashboard_data': dash.data, + 'dashboard_data': dashboard_data, 'datasources': {ds.uid: ds.data for ds in datasources}, } From 20645375642b88f7d525a0fecb424f4587edf41c Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 18 Apr 2017 12:56:16 -0700 Subject: [PATCH 2/2] Addressing comments --- superset/assets/javascripts/components/ModalTrigger.jsx | 3 --- superset/assets/javascripts/dashboard/components/Controls.jsx | 1 - 2 files changed, 4 deletions(-) diff --git a/superset/assets/javascripts/components/ModalTrigger.jsx b/superset/assets/javascripts/components/ModalTrigger.jsx index aaff97861b0a7..aee93ba826878 100644 --- a/superset/assets/javascripts/components/ModalTrigger.jsx +++ b/superset/assets/javascripts/components/ModalTrigger.jsx @@ -15,7 +15,6 @@ const propTypes = { bsSize: PropTypes.string, className: PropTypes.string, tooltip: PropTypes.string, - disabled: PropTypes.bool, }; const defaultProps = { @@ -25,7 +24,6 @@ const defaultProps = { isButton: false, bsSize: null, className: '', - disabled: false, }; export default class ModalTrigger extends React.Component { @@ -82,7 +80,6 @@ export default class ModalTrigger extends React.Component { className="modal-trigger" tooltip={this.props.tooltip} onClick={this.open} - disabled={this.props.disabled} > {this.props.triggerNode} {this.renderModal()} diff --git a/superset/assets/javascripts/dashboard/components/Controls.jsx b/superset/assets/javascripts/dashboard/components/Controls.jsx index 75fe1bc0b53b4..09b8937e24263 100644 --- a/superset/assets/javascripts/dashboard/components/Controls.jsx +++ b/superset/assets/javascripts/dashboard/components/Controls.jsx @@ -95,7 +95,6 @@ class Controls extends React.PureComponent {