Introduce UPDATE_DETAILS action

pull/852/head
Andrew Watkins 2017-02-07 11:34:57 -08:00
parent 6f557aa685
commit a31518de9c
3 changed files with 35 additions and 0 deletions

View File

@ -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);
});
});

View File

@ -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',

View File

@ -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;
}