grafana icon indicating copy to clipboard operation
grafana copied to clipboard

Alerting: implement "rename / move / update" for `useProduceNewRuleGroup`

Open gillesdemey opened this issue 1 year ago • 0 comments

What is this feature?

So this PR does two things;

  1. It refactors the internals of the useProduceNewRuleGroup hook

This moves the logic for what to do with the new rule group definition to the wrapper hooks instead of having a large hook that deals with different kinds of actions.

Even though the diff is large it should make the new code quite a bit more readable and doesn't conflate responsibilities.

  1. It implements three new hooks; "move", "rename" and update of a rule group.

Moving a rule group means it goes to another namespace, optionally under a different group name. We do not allow merging of rules groups prior to the PR and we don't allow it either in this one. If there is demand for this we can add it later as the focus of this PR is not on adding new functionality.

The redux action we were dispatching prior to this PR kinda tried to do all 3 of those actions which made it a bit hard to reason about the code and didn't allow us to split off some of this functionality in the future from the existing modal UI.

Special notes for your reviewer:

I tried to go as far as I could without the refactoring but adding too much logic to the useProduceNewRuleGroup hook made it very awkward to read and reason about, hopefully I can redeem my future self if any of us get back to this code base in 6 months or a year from now and can still reason about it.

Todo

  • [ ] Write tests for these new hooks

gillesdemey avatar Jun 25 '24 16:06 gillesdemey