Custom Threshold editor

Hello there, I am using grafana 7 on ubuntu, and I am trying to build a custom threshold editor for one of the panels I’m working on. This custom threshold is the same as the grafana’s one but I just want to add the possibility to use the metric as a threshold value.
So to do that, I tried to take the code of the threshold editor available here : grafana/ThresholdsEditor.tsx at main · grafana/grafana · GitHub
and edit it in a way where I can add a switch button and a select list.
I have the UI that I want, but the problem is that I cant connect the backend with the UI, because I don’t fully understand the code in the link above
I don’t have an error, but the editor is adding thresholds I cant access, and deleting them.
If anyone had the same problem with any other grafana component I would appreciate any help possible.
best,