Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class ChartContainer extends React.PureComponent {

componentDidUpdate(prevProps) {
if (
this.props.queryResponse &&
(
prevProps.queryResponse !== this.props.queryResponse ||
prevProps.height !== this.props.height ||
Expand Down
4 changes: 4 additions & 0 deletions superset/assets/javascripts/explorev2/components/Control.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ export default class Control extends React.PureComponent {
super(props);
this.validate = this.validate.bind(this);
this.onChange = this.onChange.bind(this);
this.validateAndSetValue(props.value, []);
}
onChange(value, errors) {
this.validateAndSetValue(value, errors);
}
validateAndSetValue(value, errors) {
let validationErrors = this.validate(value);
if (errors && errors.length > 0) {
validationErrors = validationErrors.concat(errors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ExploreViewContainer extends React.Component {
}

componentDidUpdate() {
if (this.props.triggerQuery) {
if (this.props.triggerQuery && !this.hasErrors()) {
this.runQuery();
}
}
Expand Down Expand Up @@ -95,6 +95,10 @@ class ExploreViewContainer extends React.Component {
toggleModal() {
this.setState({ showModal: !this.state.showModal });
}
hasErrors() {
const ctrls = this.props.controls;
return Object.keys(ctrls).some(k => ctrls[k].validationErrors.length > 0);
}
renderErrorMessage() {
// Returns an error message as a node if any errors are in the store
const errors = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const propTypes = {
onSave: PropTypes.func,
onStop: PropTypes.func,
loading: PropTypes.bool,
errorMessage: PropTypes.string,
errorMessage: PropTypes.node,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

could use !! to convert the truthy/falsey value to a boolean.

disabled={!!errorMessage}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oh nice, never seen that before

};

const defaultProps = {
Expand Down Expand Up @@ -37,6 +37,7 @@ export default function QueryAndSaveBtns(
className="query"
onClick={onQuery}
bsStyle={qryButtonStyle}
disabled={!!errorMessage}
>
<i className="fa fa-bolt" /> Query
</Button>
Expand Down
2 changes: 1 addition & 1 deletion superset/assets/javascripts/explorev2/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { exploreReducer } from './reducers/exploreReducer';
// Initial state
const bootstrappedState = Object.assign(
bootstrapData, {
chartStatus: 'loading',
chartStatus: null,
chartUpdateEndTime: null,
chartUpdateStartTime: now(),
dashboards: [],
Expand Down
4 changes: 0 additions & 4 deletions superset/assets/javascripts/explorev2/stores/visTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,6 @@ const visTypes = {
},
],
controlOverrides: {
metrics: {
default: null,
validators: null,
},
time_grain_sqla: {
default: null,
},
Expand Down
2 changes: 1 addition & 1 deletion superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def query_obj(self):
"""Building a query object"""
form_data = self.form_data
groupby = form_data.get("groupby") or []
metrics = form_data.get("metrics") or ['count']
metrics = form_data.get("metrics") or []

# extra_filters are temporary/contextual filters that are external
# to the slice definition. We use those for dynamic interactive
Expand Down