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'
|
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,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue