From 2fc7b73ea00c109905f07c54325c437e2720921d Mon Sep 17 00:00:00 2001 From: Maycon Santos Date: Wed, 1 Nov 2023 11:56:12 +0100 Subject: [PATCH] Fix/blank page on empty policy groups (#292) validate null sources and destinations fields --- src/views/Settings.tsx | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/views/Settings.tsx b/src/views/Settings.tsx index 7210b11f..c8dd1f83 100644 --- a/src/views/Settings.tsx +++ b/src/views/Settings.tsx @@ -305,17 +305,20 @@ export const Settings = () => { const createSingleArrayForPolicy: any = []; policies.map((aControl: any) => { const cSingleAccessArray = aControl.allGroups ? aControl.allGroups : []; - aControl.rules[0].destinations.forEach((destination: any) => { - if (cSingleAccessArray.indexOf(destination.id) === -1) { - cSingleAccessArray.push(destination.id); - } - }); - - aControl.rules[0].sources.forEach((source: any) => { - if (cSingleAccessArray.indexOf(source.id) === -1) { - cSingleAccessArray.push(source.id); - } - }); + if (aControl.rules[0].destinations) { + aControl.rules[0].destinations.forEach((destination: any) => { + if (cSingleAccessArray.indexOf(destination.id) === -1) { + cSingleAccessArray.push(destination.id); + } + }); + } + if (aControl.rules[0].sources) { + aControl.rules[0].sources.forEach((source: any) => { + if (cSingleAccessArray.indexOf(source.id) === -1) { + cSingleAccessArray.push(source.id); + } + }); + } aControl["cSingleAccessArray"] = cSingleAccessArray; createSingleArrayForPolicy.push(aControl);