diff --git a/ui/spec/kapacitor/reducers/rulesSpec.js b/ui/spec/kapacitor/reducers/rulesSpec.js index fb49ab930..c2cfd9f8e 100644 --- a/ui/spec/kapacitor/reducers/rulesSpec.js +++ b/ui/spec/kapacitor/reducers/rulesSpec.js @@ -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); + }); }); diff --git a/ui/src/kapacitor/actions/view/index.js b/ui/src/kapacitor/actions/view/index.js index 250757d98..db42d6f6a 100644 --- a/ui/src/kapacitor/actions/view/index.js +++ b/ui/src/kapacitor/actions/view/index.js @@ -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', diff --git a/ui/src/kapacitor/reducers/rules.js b/ui/src/kapacitor/reducers/rules.js index 57acb91c6..68fb345aa 100644 --- a/ui/src/kapacitor/reducers/rules.js +++ b/ui/src/kapacitor/reducers/rules.js @@ -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; }