From 8c136f12d4c3dbc508d7da3baa2ac42398f1c0fa Mon Sep 17 00:00:00 2001 From: Shahidullah Muffakir Date: Sun, 1 Sep 2024 04:45:42 +0530 Subject: [PATCH 1/2] ensure the Required toggle is turned off automatically when all subtags are disabled --- src/pages/workspace/tags/WorkspaceViewTagsPage.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx b/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx index b5c4bfa9d038..dc0e61d4ff0b 100644 --- a/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx @@ -231,7 +231,9 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) { /> ); }; - + if (!Object.values(currentPolicyTag?.tags ?? {}).some((tag) => tag.enabled)) { + Tag.setPolicyTagsRequired(policyID, false, route.params.orderWeight) + } const navigateToEditTag = () => { Navigation.navigate(ROUTES.WORKSPACE_EDIT_TAGS.getRoute(route.params.policyID, currentPolicyTag?.orderWeight)); }; From 10af826fd161b21029fc565b3a8b5e3763053383 Mon Sep 17 00:00:00 2001 From: Shahidullah Muffakir Date: Wed, 4 Sep 2024 03:21:17 +0530 Subject: [PATCH 2/2] Updated condition to call setPolicyTagsRequired only when necessary. --- src/pages/workspace/tags/WorkspaceViewTagsPage.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx b/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx index dc0e61d4ff0b..fae17a847c98 100644 --- a/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx @@ -231,9 +231,11 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) { /> ); }; - if (!Object.values(currentPolicyTag?.tags ?? {}).some((tag) => tag.enabled)) { - Tag.setPolicyTagsRequired(policyID, false, route.params.orderWeight) + + if (!!currentPolicyTag?.required && !Object.values(currentPolicyTag?.tags ?? {}).some((tag) => tag.enabled)) { + Tag.setPolicyTagsRequired(policyID, false, route.params.orderWeight); } + const navigateToEditTag = () => { Navigation.navigate(ROUTES.WORKSPACE_EDIT_TAGS.getRoute(route.params.policyID, currentPolicyTag?.orderWeight)); };