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'
export const addQuery = (options = {}) => ({
export const addQuery = () => ({
type: 'DE_ADD_QUERY',
payload: {
queryID: uuid.v4(),
options,
},
})

View File

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