Commit ff13bd4a authored by Vitaly Slobodin's avatar Vitaly Slobodin Committed by Paul Slaughter

Replace $emit call with single arg in EscalationPolicies

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64514
parent c1e45452
...@@ -97,7 +97,7 @@ export default { ...@@ -97,7 +97,7 @@ export default {
addRule() { addRule() {
this.rules.push({ ...cloneDeep(DEFAULT_ESCALATION_RULE), key: uniqueId() }); this.rules.push({ ...cloneDeep(DEFAULT_ESCALATION_RULE), key: uniqueId() });
}, },
updateEscalationRules(index, rule) { updateEscalationRules({ rule, index }) {
this.rules[index] = { ...this.rules[index], ...rule }; this.rules[index] = { ...this.rules[index], ...rule };
this.emitRulesUpdate(); this.emitRulesUpdate();
}, },
......
...@@ -113,11 +113,14 @@ export default { ...@@ -113,11 +113,14 @@ export default {
this.emitUpdate(); this.emitUpdate();
}, },
emitUpdate() { emitUpdate() {
this.$emit('update-escalation-rule', this.index, { this.$emit('update-escalation-rule', {
oncallScheduleIid: parseInt(this.oncallScheduleIid, 10), index: this.index,
action: this.action, rule: {
status: this.status, oncallScheduleIid: parseInt(this.oncallScheduleIid, 10),
elapsedTimeSeconds: parseInt(this.elapsedTimeSeconds, 10), action: this.action,
status: this.status,
elapsedTimeSeconds: parseInt(this.elapsedTimeSeconds, 10),
},
}); });
}, },
}, },
......
...@@ -85,7 +85,7 @@ describe('AddEscalationPolicyForm', () => { ...@@ -85,7 +85,7 @@ describe('AddEscalationPolicyForm', () => {
elapsedTimeSeconds: 30, elapsedTimeSeconds: 30,
oncallScheduleIid: 2, oncallScheduleIid: 2,
}; };
findRules().at(0).vm.$emit('update-escalation-rule', 0, updatedRule); findRules().at(0).vm.$emit('update-escalation-rule', { index: 0, rule: updatedRule });
expect(wrapper.emitted('update-escalation-policy-form')[0]).toEqual([ expect(wrapper.emitted('update-escalation-policy-form')[0]).toEqual([
{ field: 'rules', value: [expect.objectContaining(updatedRule)] }, { field: 'rules', value: [expect.objectContaining(updatedRule)] },
]); ]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment