Refactor a ADD_QUERY reducer to use spread operator; remove unused param

pull/10616/head
Jared Scheib 2017-09-07 13:10:11 -04:00
parent f26885aa45
commit 82f93819c4
2 changed files with 11 additions and 16 deletions

View File

@ -6,11 +6,10 @@ import {errorThrown} from 'shared/actions/errors'
import {DEFAULT_DATA_EXPLORER_GROUP_BY_INTERVAL} from 'src/data_explorer/constants' import {DEFAULT_DATA_EXPLORER_GROUP_BY_INTERVAL} from 'src/data_explorer/constants'
export const addQuery = (options = {}) => ({ export const addQuery = () => ({
type: 'DE_ADD_QUERY', type: 'DE_ADD_QUERY',
payload: { payload: {
queryID: uuid.v4(), queryID: uuid.v4(),
options,
}, },
}) })

View File

@ -41,16 +41,17 @@ const queryConfigs = (state = {}, action) => {
} }
case 'DE_ADD_QUERY': { case 'DE_ADD_QUERY': {
const {queryID, options} = action.payload const {queryID} = action.payload
const nextState = Object.assign({}, state, {
[queryID]: Object.assign(
{},
defaultQueryConfig({id: queryID}),
options
),
})
return nextState return {
...state,
[queryID]: defaultQueryConfig({id: queryID}),
}
}
case 'DE_DELETE_QUERY': {
const {queryID} = action.payload
return _.omit(state, queryID)
} }
case 'DE_UPDATE_QUERY_CONFIG': { case 'DE_UPDATE_QUERY_CONFIG': {
@ -85,11 +86,6 @@ const queryConfigs = (state = {}, action) => {
}) })
} }
case 'DE_DELETE_QUERY': {
const {queryID} = action.payload
return _.omit(state, queryID)
}
case 'DE_TOGGLE_FIELD': { case 'DE_TOGGLE_FIELD': {
const {queryId, fieldFunc} = action.payload const {queryId, fieldFunc} = action.payload
const nextQueryConfig = toggleField(state[queryId], fieldFunc) const nextQueryConfig = toggleField(state[queryId], fieldFunc)