Skip to content

Commit

Permalink
Validate that state control fields are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreythewang committed Jan 24, 2018
1 parent 7e42d47 commit 1f54180
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions superset/assets/javascripts/explore/stores/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -566,13 +566,13 @@ export const controls = {
mapStateToProps: (state) => {
let choices = [];
if (state.controls && state.datasource) {
const gbSet = new Set(state.controls.groupby.value);
const gbSet = new Set((state.controls.groupby || {}).value || []);
const gbSelectables = state.datasource.all_cols.filter(elem => gbSet.has(elem[0]));

const mSet = new Set(state.controls.metrics.value);
const mSet = new Set((state.controls.metrics || {}).value || []);
const mSelectables = state.datasource.metrics_combo.filter(elem => mSet.has(elem[0]));

const cSet = new Set(state.controls.all_columns.value);
const cSet = new Set((state.controls.all_columns || {}).value || []);
const cSelectables = state.datasource.all_cols.filter(elem => cSet.has(elem[0]));
choices = [...gbSelectables, ...mSelectables, ...cSelectables];
} else {
Expand Down Expand Up @@ -604,13 +604,13 @@ export const controls = {
mapStateToProps: (state) => {
let choices = [];
if (state.controls && state.datasource) {
const gbSet = new Set(state.controls.groupby.value);
const gbSet = new Set((state.controls.groupby || {}).value || []);
const gbSelectables = state.datasource.all_cols.filter(elem => gbSet.has(elem[0]));

const mSet = new Set(state.controls.metrics.value);
const mSet = new Set((state.controls.metrics || {}).value || []);
const mSelectables = state.datasource.metrics_combo.filter(elem => mSet.has(elem[0]));

const cSet = new Set(state.controls.all_columns.value);
const cSet = new Set((state.controls.all_columns || {}).value || []);
const cSelectables = state.datasource.all_cols.filter(elem => cSet.has(elem[0]));
choices = [...gbSelectables, ...mSelectables, ...cSelectables];
} else {
Expand All @@ -632,10 +632,10 @@ export const controls = {
mapStateToProps: (state) => {
let choices = [];
if (state.controls && state.datasource) {
const gbSet = new Set(state.controls.groupby.value);
const gbSet = new Set((state.controls.groupby || {}).value || []);
const gbSelectables = state.datasource.all_cols.filter(elem => gbSet.has(elem[0]));

const cSet = new Set(state.controls.all_columns.value);
const cSet = new Set((state.controls.all_columns || {}).value || []);
const cSelectables = state.datasource.all_cols.filter(elem => cSet.has(elem[0]));
choices = [...gbSelectables, ...cSelectables];
} else {
Expand Down

0 comments on commit 1f54180

Please sign in to comment.