Add timeShift actions + spec to kapa queryConfig
parent
e89f15934d
commit
6ef7fa8090
|
@ -325,4 +325,18 @@ describe('Chronograf.Reducers.Kapacitor.queryConfigs', () => {
|
||||||
expect(nextState[queryID].groupBy.time).to.equal(time)
|
expect(nextState[queryID].groupBy.time).to.equal(time)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('KAPA_TIME_SHIFT', () => {
|
||||||
|
it('can shift the time', () => {
|
||||||
|
const initialState = {
|
||||||
|
[queryID]: buildInitialState(queryID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const shift = {quantity: 1, unit: 'd', duration: '1d'}
|
||||||
|
const action = timeShift(queryID, shift)
|
||||||
|
const nextState = reducer(initialState, action)
|
||||||
|
|
||||||
|
expect(nextState[queryID].shift).to.deep.equal([shift])
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -69,3 +69,11 @@ export const removeFuncs = (queryID, fields) => ({
|
||||||
fields,
|
fields,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const timeShift = (queryID, shift) => ({
|
||||||
|
type: 'KAPA_TIME_SHIFT',
|
||||||
|
payload: {
|
||||||
|
queryID,
|
||||||
|
shift,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
|
@ -125,6 +125,13 @@ const queryConfigs = (state = {}, action) => {
|
||||||
// fields with no functions cannot have a group by time
|
// fields with no functions cannot have a group by time
|
||||||
return {...state, [queryID]: nextQuery}
|
return {...state, [queryID]: nextQuery}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'KAPA_TIME_SHIFT': {
|
||||||
|
const {queryID, shift} = action.payload
|
||||||
|
const nextQuery = timeShift(state[queryID], shift)
|
||||||
|
|
||||||
|
return {...state, [queryID]: nextQuery}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue