mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
[SQLLab] Fix updating the database state. (#1225)
This commit is contained in:
parent
e11ef994bb
commit
9795e4a532
@ -1,6 +1,9 @@
|
|||||||
const $ = window.$ = require('jquery');
|
const $ = window.$ = require('jquery');
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { bindActionCreators } from 'redux';
|
||||||
import Select from 'react-select';
|
import Select from 'react-select';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import * as Actions from '../actions';
|
||||||
|
|
||||||
class DatabaseSelect extends React.Component {
|
class DatabaseSelect extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -11,7 +14,7 @@ class DatabaseSelect extends React.Component {
|
|||||||
databaseId: null,
|
databaseId: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
componentWillMount() {
|
componentDidMount() {
|
||||||
this.fetchDatabaseOptions();
|
this.fetchDatabaseOptions();
|
||||||
}
|
}
|
||||||
changeDb(db) {
|
changeDb(db) {
|
||||||
@ -25,6 +28,7 @@ class DatabaseSelect extends React.Component {
|
|||||||
$.get(url, (data) => {
|
$.get(url, (data) => {
|
||||||
const options = data.result.map((db) => ({ value: db.id, label: db.database_name }));
|
const options = data.result.map((db) => ({ value: db.id, label: db.database_name }));
|
||||||
this.setState({ databaseOptions: options, databaseLoading: false });
|
this.setState({ databaseOptions: options, databaseLoading: false });
|
||||||
|
this.props.actions.setDatabases(data.result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
@ -46,6 +50,13 @@ class DatabaseSelect extends React.Component {
|
|||||||
|
|
||||||
DatabaseSelect.propTypes = {
|
DatabaseSelect.propTypes = {
|
||||||
onChange: React.PropTypes.func,
|
onChange: React.PropTypes.func,
|
||||||
|
actions: React.PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default DatabaseSelect;
|
function mapDispatchToProps(dispatch) {
|
||||||
|
return {
|
||||||
|
actions: bindActionCreators(Actions, dispatch),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(null, mapDispatchToProps)(DatabaseSelect);
|
||||||
|
Loading…
Reference in New Issue
Block a user