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

Save modal component for explore v2 #1612

Merged
merged 9 commits into from
Nov 18, 2016

Conversation

vera-liu
Copy link
Contributor

@vera-liu vera-liu commented Nov 16, 2016

Done:

  • Added a SaveModal component, triggered by save button in QueryAndSaveButton
  • url params for saveOrOverwriteSlice stay the same as in v1
  • when user updates control panel and save the slice, new form_data will be saved into the slice
  • Added specs for SaveModal
  • This PR includes changes from https://github.com/airbnb/superset/pull/1610 since datasource_name is required in saveOrOverwriteSlice url

screen shot 2016-11-16 at 9 22 14 am

Todo:

  • add Alert to explore v2 for all ajax calls and exception handling

needs-review @mistercrunch @ascott

@vera-liu vera-liu force-pushed the vliu_reactify_save_modal branch from 8a8771e to bf227e2 Compare November 16, 2016 17:29

fetchDashboards() {
const url = '/dashboardmodelviewasync/api/read?_flt_0_owners=' + this.props.user_id;
$.get(url, function (data) {
Copy link

@ascott ascott Nov 16, 2016

Choose a reason for hiding this comment

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

looks like we're duplicating this $.get here as well: https://github.com/airbnb/superset/pull/1612/files#diff-cb97812fa1c826050e9d4b6d69438938R119

we should move this fetching logic to the actions file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we want to keep dashboards in global store? right now we only use them in SaveModal, I'm not sure if we would use them in other components.

Copy link

Choose a reason for hiding this comment

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

we may not use this action in other components yet, but it's great to keep all the fetching logic in one place and keep the components leaner. could be an opportunity to start an actions file for dashboard actions, but i think we could put this fetch in the explore actions for now.

}
this.setState({ dashboards: choices });
}.bind(this));
$('input[name=add_to_dash]').change(setButtonsState);
Copy link

Choose a reason for hiding this comment

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

seems like we have a lot of jquery dom manipulation happening in this component. can we do this in a more react-y way and avoid using jquery for dom manipulation?

return { type: SET_FIELD_VALUE, key, value, label };
}

export const SAVE_SLICE_SUCCEEDED = 'SAVE_SLICE_SUCCEEDED';
Copy link

Choose a reason for hiding this comment

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

do we need SAVE_SLICE_STARTED to show feedback to the user while we are saving?

constructor(props) {
super(props);
this.state = {
save_to_dashboard_id: null,
Copy link

Choose a reason for hiding this comment

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

can this be camelCase?

@ascott
Copy link

ascott commented Nov 16, 2016

would love to see all async/fetching logic in an actions file and would love to see less jquery dom manipulation in favor of react patterns in the save modal component. otherwise, looking good!

@vera-liu vera-liu force-pushed the vliu_reactify_save_modal branch 2 times, most recently from 0af1517 to 706b7d5 Compare November 17, 2016 22:15
@vera-liu
Copy link
Contributor Author

Done:

  • moved ajax to action creator
  • more react state instead of jquery
  • added alerts

PTAL @ascott

@vera-liu vera-liu force-pushed the vliu_reactify_save_modal branch from 2fbe00d to f6ba5bf Compare November 18, 2016 19:34
@@ -0,0 +1,249 @@
/* eslint camel-case: 0 */
import React, { PropTypes } from 'react';
const $ = window.$ = require('jquery');
Copy link

Choose a reason for hiding this comment

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

can we use import $ from 'jquery'; here? don't think we need window.$ in this case.

/>
</Alert>
}
<form>
Copy link

@ascott ascott Nov 18, 2016

Choose a reason for hiding this comment

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

would be great to use the react-bootstrap form components here, which we are using for the control panel container too: https://react-bootstrap.github.io/components.html#forms

@ascott
Copy link

ascott commented Nov 18, 2016

yes! this looks so much better! it'll be easier to maintain/iterate on in the future!

just one comment about using react-bootstrap forms, could do that in this PR or another, otherwise LGTM!

@vera-liu vera-liu force-pushed the vliu_reactify_save_modal branch from 609750b to 71b420a Compare November 18, 2016 21:39
@vera-liu vera-liu merged commit 38e94b9 into apache:master Nov 18, 2016
@vera-liu vera-liu deleted the vliu_reactify_save_modal branch November 21, 2016 17:26
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.14.0 labels Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.14.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants