From 26f165e6b8807353ded43aebd9e97c6bbbdd19ce Mon Sep 17 00:00:00 2001 From: Maycon Santos Date: Wed, 1 Nov 2023 11:02:28 +0100 Subject: [PATCH 1/2] Fix blank settings page on empty policy groups --- 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..0f9bdf42 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.length > 0) { + aControl.rules[0].destinations.forEach((destination: any) => { + if (cSingleAccessArray.indexOf(destination.id) === -1) { + cSingleAccessArray.push(destination.id); + } + }); + } + if (aControl.rules[0].sources.length > 0) { + aControl.rules[0].sources.forEach((source: any) => { + if (cSingleAccessArray.indexOf(source.id) === -1) { + cSingleAccessArray.push(source.id); + } + }); + } aControl["cSingleAccessArray"] = cSingleAccessArray; createSingleArrayForPolicy.push(aControl); From 2148b6bf01ae36fcb2ffd3f73ed82e66f59b7d9d Mon Sep 17 00:00:00 2001 From: Maycon Santos Date: Wed, 1 Nov 2023 11:45:01 +0100 Subject: [PATCH 2/2] validate null sources and destinations fields --- src/views/Settings.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/Settings.tsx b/src/views/Settings.tsx index 0f9bdf42..c8dd1f83 100644 --- a/src/views/Settings.tsx +++ b/src/views/Settings.tsx @@ -305,14 +305,14 @@ export const Settings = () => { const createSingleArrayForPolicy: any = []; policies.map((aControl: any) => { const cSingleAccessArray = aControl.allGroups ? aControl.allGroups : []; - if (aControl.rules[0].destinations.length > 0) { + 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.length > 0) { + if (aControl.rules[0].sources) { aControl.rules[0].sources.forEach((source: any) => { if (cSingleAccessArray.indexOf(source.id) === -1) { cSingleAccessArray.push(source.id);