Refactor a ADD_QUERY reducer to use spread operator; remove unused param
parent
f26885aa45
commit
82f93819c4
|
@ -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,
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue