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 dashboard edit button is disabled #2634

Merged
merged 2 commits into from
Apr 18, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions superset/assets/javascripts/components/ModalTrigger.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const propTypes = {
bsSize: PropTypes.string,
className: PropTypes.string,
tooltip: PropTypes.string,
disabled: PropTypes.bool,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in what instance are we passing a disabled flag for <ModalTrigger />?

Copy link
Member Author

@mistercrunch mistercrunch Apr 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, I ended up backtracking on this approach when I realized I could disable my own triggerNode prop that I pass to it. I thought it wouldn't hurt to leave it, but I'm removing it now.

};

const defaultProps = {
Expand All @@ -24,6 +25,7 @@ const defaultProps = {
isButton: false,
bsSize: null,
className: '',
disabled: false,
};

export default class ModalTrigger extends React.Component {
Expand Down Expand Up @@ -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()}
Expand Down
20 changes: 11 additions & 9 deletions superset/assets/javascripts/dashboard/components/Controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down Expand Up @@ -81,26 +80,29 @@ class Controls extends React.PureComponent {
onChange={this.changeCss.bind(this)}
/>
<Button
disabled={!canSave}
onClick={() => { window.location = emailLink; }}
>
<i className="fa fa-envelope" />
</Button>
<Button
disabled={!dashboard.dash_edit_perm}
onClick={() => {
window.location = `/dashboardmodelview/edit/${dashboard.id}`;
}}
tooltip="Edit this dashboard's property"
tooltip="Edit this dashboard's properties"
>
<i className="fa fa-edit" />
</Button>
<SaveModal
dashboard={dashboard}
disabled={!dashboard.dash_save_perm}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does <SaveModal /> need a disabled prop?

css={this.state.css}
triggerNode={
<i className="fa fa-save" />
<Button disabled={!dashboard.dash_save_perm}>
<i className="fa fa-save" />
</Button>
}
/>
<Button
onClick={() => { window.location = emailLink; }}
>
<i className="fa fa-envelope" />
</Button>
</ButtonGroup>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ class SaveModal extends React.PureComponent {
<ModalTrigger
ref={(modal) => { this.modal = modal; }}
triggerNode={this.props.triggerNode}
isButton
modalTitle="Save Dashboard"
modalBody={
<FormGroup>
Expand Down
7 changes: 3 additions & 4 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
}

Expand Down