From cf4870cd0678dd753d730b045892572cd62d9aec Mon Sep 17 00:00:00 2001 From: "grafana-delivery-bot[bot]" <132647405+grafana-delivery-bot[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 14:15:22 +0200 Subject: [PATCH] [v11.0.x] Alerting: Fix removing nested policy (#85247) --- .../features/alerting/unified/utils/routeTree.test.ts | 9 ++++++--- public/app/features/alerting/unified/utils/routeTree.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/public/app/features/alerting/unified/utils/routeTree.test.ts b/public/app/features/alerting/unified/utils/routeTree.test.ts index 8fbefd5462a..19fd6016d2c 100644 --- a/public/app/features/alerting/unified/utils/routeTree.test.ts +++ b/public/app/features/alerting/unified/utils/routeTree.test.ts @@ -65,14 +65,17 @@ describe('omitRouteFromRouteTree', () => { receiver: 'root', routes: [ { id: 'route-2', receiver: 'receiver-2' }, - { id: 'route-3', receiver: 'receiver-3' }, + { id: 'route-3', receiver: 'receiver-3', routes: [{ id: 'route-4', receiver: 'receiver-4' }] }, ], }; - expect(omitRouteFromRouteTree({ id: 'route-2' }, tree)).toEqual({ + expect(omitRouteFromRouteTree({ id: 'route-4' }, tree)).toEqual({ id: 'route-1', receiver: 'root', - routes: [{ id: 'route-3', receiver: 'receiver-3', routes: undefined }], + routes: [ + { id: 'route-2', receiver: 'receiver-2' }, + { id: 'route-3', receiver: 'receiver-3', routes: [] }, + ], }); }); diff --git a/public/app/features/alerting/unified/utils/routeTree.ts b/public/app/features/alerting/unified/utils/routeTree.ts index 426979f0e95..4cad4826887 100644 --- a/public/app/features/alerting/unified/utils/routeTree.ts +++ b/public/app/features/alerting/unified/utils/routeTree.ts @@ -58,7 +58,7 @@ export const omitRouteFromRouteTree = (findRoute: RouteWithID, routeTree: RouteW return acc; } - acc.push(route); + acc.push(findAndOmit(route)); return acc; }, []), };