mirror of
https://github.com/apache/superset.git
synced 2026-04-10 03:45:22 +00:00
fix local state 'columns' (#2896)
* fix local state 'columns' * fix method name per code review
This commit is contained in:
@@ -41,28 +41,26 @@ class VisualizeModal extends React.PureComponent {
|
||||
this.state = {
|
||||
chartType: CHART_TYPES[0],
|
||||
datasourceName: this.datasourceName(),
|
||||
columns: {},
|
||||
columns: this.getColumnFromProps(),
|
||||
hints: [],
|
||||
};
|
||||
}
|
||||
componentDidMount() {
|
||||
this.validate();
|
||||
}
|
||||
componentWillReceiveProps(nextProps) {
|
||||
this.setStateFromProps(nextProps);
|
||||
}
|
||||
setStateFromProps(props) {
|
||||
getColumnFromProps() {
|
||||
const props = this.props;
|
||||
if (!props ||
|
||||
!props.query ||
|
||||
!props.query.results ||
|
||||
!props.query.results.columns) {
|
||||
return;
|
||||
return {};
|
||||
}
|
||||
const columns = {};
|
||||
props.query.results.columns.forEach((col) => {
|
||||
columns[col.name] = col;
|
||||
});
|
||||
this.setState({ columns });
|
||||
return columns;
|
||||
}
|
||||
datasourceName() {
|
||||
const { query } = this.props;
|
||||
|
||||
Reference in New Issue
Block a user