Fix bug to ensure GROUP BY is not added to toggled func-less field

pull/10616/head
Jared Scheib 2017-09-05 12:02:15 -04:00
parent 5805b17ab9
commit 502ac19afe
1 changed files with 16 additions and 7 deletions

View File

@ -45,14 +45,23 @@ export const fill = (queryId, value) => ({
},
})
// all fields implicitly have a function applied to them, so consequently
// we need to set the auto group by time
export const toggleFieldWithGroupByInterval = (
queryID,
fieldFunc
) => dispatch => {
// all fields implicitly have a function applied to them by default, unless
// it was explicitly removed previously, so set the auto group by time except
// under that removal condition
export const toggleFieldWithGroupByInterval = (queryID, fieldFunc) => (
dispatch,
getState
) => {
dispatch(toggleField(queryID, fieldFunc))
dispatch(groupByTime(queryID, DEFAULT_DATA_EXPLORER_GROUP_BY_INTERVAL))
// toggleField determines whether to add a func, so now check state for funcs
// presence, and if present then apply default group by time
const newFieldFunc = getState().dataExplorerQueryConfigs[queryID].fields.find(
({field}) => field === fieldFunc.field
)
// newFieldFunc could be undefined if it was toggled for removal
if (newFieldFunc && newFieldFunc.funcs.length) {
dispatch(groupByTime(queryID, DEFAULT_DATA_EXPLORER_GROUP_BY_INTERVAL))
}
}
export const applyFuncsToField = (queryId, fieldFunc) => ({