mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
Vliu put datasource in store (#1610)
* Move datasource from global store object to form_data * Moved datasource_id and datasource_name to form_data * Refetch defaultFormData when switching datasource * Fixed js tests
This commit is contained in:
@@ -9,7 +9,6 @@ import ControlPanelSection from './ControlPanelSection';
|
||||
import FieldSetRow from './FieldSetRow';
|
||||
|
||||
const propTypes = {
|
||||
datasource_id: PropTypes.number.isRequired,
|
||||
datasource_type: PropTypes.string.isRequired,
|
||||
actions: PropTypes.object.isRequired,
|
||||
fields: PropTypes.object.isRequired,
|
||||
@@ -20,14 +19,24 @@ const propTypes = {
|
||||
|
||||
class ControlPanelsContainer extends React.Component {
|
||||
componentWillMount() {
|
||||
const { datasource_id, datasource_type } = this.props;
|
||||
const datasource_id = this.props.form_data.datasource;
|
||||
const datasource_type = this.props.datasource_type;
|
||||
if (datasource_id) {
|
||||
this.props.actions.fetchFieldOptions(datasource_id, datasource_type);
|
||||
}
|
||||
}
|
||||
|
||||
onChange(name, value) {
|
||||
this.props.actions.setFieldValue(name, value);
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (nextProps.form_data.datasource !== this.props.form_data.datasource) {
|
||||
if (nextProps.form_data.datasource) {
|
||||
this.props.actions.fetchFieldOptions(
|
||||
nextProps.form_data.datasource, nextProps.datasource_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onChange(name, value, label) {
|
||||
this.props.actions.setFieldValue(name, value, label);
|
||||
}
|
||||
|
||||
sectionsToRender() {
|
||||
@@ -82,7 +91,6 @@ function mapStateToProps(state) {
|
||||
return {
|
||||
isDatasourceMetaLoading: state.isDatasourceMetaLoading,
|
||||
fields: state.fields,
|
||||
datasource_id: state.datasource_id,
|
||||
datasource_type: state.datasource_type,
|
||||
form_data: state.viz.form_data,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user