From 3fbc84bb437205427e9b66db6d175f3a376d76c8 Mon Sep 17 00:00:00 2001 From: Dexter Lee Date: Thu, 31 Mar 2022 10:16:54 -0700 Subject: [PATCH] fix(policy): Remove all from the resource type choices (#4538) * Remove all from the resource type choices * Fix empty case * Fix privileges --- .../src/app/policy/PolicyPrivilegeForm.tsx | 16 +++++++++------- datahub-web-react/src/app/policy/policyUtils.ts | 3 +++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/datahub-web-react/src/app/policy/PolicyPrivilegeForm.tsx b/datahub-web-react/src/app/policy/PolicyPrivilegeForm.tsx index 78ba0bcad8..370d2c5940 100644 --- a/datahub-web-react/src/app/policy/PolicyPrivilegeForm.tsx +++ b/datahub-web-react/src/app/policy/PolicyPrivilegeForm.tsx @@ -290,13 +290,15 @@ export default function PolicyPrivilegeForm({ )} > - {resourcePrivileges.map((resPrivs) => { - return ( - - {resPrivs.resourceTypeDisplayName} - - ); - })} + {resourcePrivileges + .filter((privs) => privs.resourceType !== 'all') + .map((resPrivs) => { + return ( + + {resPrivs.resourceTypeDisplayName} + + ); + })} )} diff --git a/datahub-web-react/src/app/policy/policyUtils.ts b/datahub-web-react/src/app/policy/policyUtils.ts index cfbc43e769..1058770e91 100644 --- a/datahub-web-react/src/app/policy/policyUtils.ts +++ b/datahub-web-react/src/app/policy/policyUtils.ts @@ -121,5 +121,8 @@ export const setFieldValues = ( fieldValues: Array, ): PolicyMatchFilter => { const restCriteria = filter.criteria?.filter((criterion) => criterion.field !== resourceFieldType) || []; + if (fieldValues.length === 0) { + return { ...filter, criteria: restCriteria }; + } return { ...filter, criteria: [...restCriteria, createCriterion(resourceFieldType, fieldValues)] }; };