fix(policy): Remove all from the resource type choices (#4538)

* Remove all from the resource type choices

* Fix empty case

* Fix privileges
This commit is contained in:
Dexter Lee 2022-03-31 10:16:54 -07:00 committed by GitHub
parent 94890c1e71
commit 3fbc84bb43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

@ -290,13 +290,15 @@ export default function PolicyPrivilegeForm({
</Tag>
)}
>
{resourcePrivileges.map((resPrivs) => {
return (
<Select.Option value={resPrivs.resourceType}>
{resPrivs.resourceTypeDisplayName}
</Select.Option>
);
})}
{resourcePrivileges
.filter((privs) => privs.resourceType !== 'all')
.map((resPrivs) => {
return (
<Select.Option value={resPrivs.resourceType}>
{resPrivs.resourceTypeDisplayName}
</Select.Option>
);
})}
</Select>
</Form.Item>
)}

View File

@ -121,5 +121,8 @@ export const setFieldValues = (
fieldValues: Array<PolicyMatchCriterionValue>,
): 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)] };
};