Skip to content

Commit

Permalink
[SQLLab] Fix updating the database state. (#1225)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkyryliuk authored Oct 3, 2016
1 parent e11ef99 commit 9795e4a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions caravel/assets/javascripts/SqlLab/components/DatabaseSelect.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const $ = window.$ = require('jquery');
import React from 'react';
import { bindActionCreators } from 'redux';
import Select from 'react-select';
import { connect } from 'react-redux';
import * as Actions from '../actions';

class DatabaseSelect extends React.Component {
constructor(props) {
Expand All @@ -11,7 +14,7 @@ class DatabaseSelect extends React.Component {
databaseId: null,
};
}
componentWillMount() {
componentDidMount() {
this.fetchDatabaseOptions();
}
changeDb(db) {
Expand All @@ -25,6 +28,7 @@ class DatabaseSelect extends React.Component {
$.get(url, (data) => {
const options = data.result.map((db) => ({ value: db.id, label: db.database_name }));
this.setState({ databaseOptions: options, databaseLoading: false });
this.props.actions.setDatabases(data.result);
});
}
render() {
Expand All @@ -46,6 +50,13 @@ class DatabaseSelect extends React.Component {

DatabaseSelect.propTypes = {
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);

0 comments on commit 9795e4a

Please sign in to comment.