From 55c5525626d33cfed4dd4908b40f1f91ffbc23af Mon Sep 17 00:00:00 2001 From: Eduard Gert Date: Wed, 11 Mar 2026 19:23:59 +0100 Subject: [PATCH] Fix resource group policy when adding single resource as destination (#581) --- src/contexts/PoliciesProvider.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/contexts/PoliciesProvider.tsx b/src/contexts/PoliciesProvider.tsx index 9e688b63..4fa3b006 100644 --- a/src/contexts/PoliciesProvider.tsx +++ b/src/contexts/PoliciesProvider.tsx @@ -60,17 +60,19 @@ export default function PoliciesProvider({ children }: Props) { }), ).then((ids) => ids.filter(Boolean) as string[]); - const hasGroups = resource.groups && resource.groups.length > 0; - - const destinations = hasGroups - ? await Promise.all( - (resource.groups as (Group | string)[]).map((g) => { + const destinations = rule.destinationResource + ? undefined + : await Promise.all( + (rule.destinations ?? []).map((g) => { if (typeof g === "string") return g; if (g.id) return g.id; return createOrUpdateGroup(g).then((r) => r.id); }), - ).then((ids) => ids.filter(Boolean) as string[]) - : null; + ).then((ids) => ids.filter(Boolean) as string[]); + + const destinationResource = rule.destinationResource + ? { id: resource.id, type: resource.type } + : undefined; return createPolicy({ ...policy, @@ -82,9 +84,7 @@ export default function PoliciesProvider({ children }: Props) { ...rule, sources, destinations, - destinationResource: hasGroups - ? undefined - : { id: resource.id, type: resource.type }, + destinationResource, }, ], } as Policy);