Introduce UPDATE_DETAILS action
parent
6f557aa685
commit
a31518de9c
|
@ -4,6 +4,7 @@ import {defaultRuleConfigs} from 'src/kapacitor/constants';
|
|||
import {
|
||||
chooseTrigger,
|
||||
updateRuleValues,
|
||||
updateDetails,
|
||||
updateMessage,
|
||||
updateAlerts,
|
||||
updateRuleName,
|
||||
|
@ -117,4 +118,20 @@ describe('Kapacitor.Reducers.rules', () => {
|
|||
expect(Object.keys(newState).length).to.equal(1);
|
||||
expect(newState[rule1]).to.equal(initialState[rule1]);
|
||||
});
|
||||
|
||||
it('can update details', () => {
|
||||
const ruleID = 1;
|
||||
const details = 'im some rule details';
|
||||
|
||||
const initialState = {
|
||||
[ruleID]: {
|
||||
id: ruleID,
|
||||
queryID: 988,
|
||||
details: '',
|
||||
}
|
||||
};
|
||||
|
||||
const newState = reducer(initialState, updateDetails(ruleID, details));
|
||||
expect(newState[ruleID].details).to.equal(details);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -87,6 +87,16 @@ export function updateMessage(ruleID, message) {
|
|||
};
|
||||
}
|
||||
|
||||
export function updateDetails(ruleID, details) {
|
||||
return {
|
||||
type: 'UPDATE_RULE_DETAILS',
|
||||
payload: {
|
||||
ruleID,
|
||||
details,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function updateAlerts(ruleID, alerts) {
|
||||
return {
|
||||
type: 'UPDATE_RULE_ALERTS',
|
||||
|
|
|
@ -85,6 +85,14 @@ export default function rules(state = {}, action) {
|
|||
delete state[ruleID];
|
||||
return Object.assign({}, state);
|
||||
}
|
||||
|
||||
case 'UPDATE_RULE_DETAILS': {
|
||||
const {ruleID, details} = action.payload;
|
||||
|
||||
return {...state, ...{
|
||||
[ruleID]: {...state[ruleID], details},
|
||||
}};
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue