diff --git a/ui/apps/platform/src/Containers/Policies/Detail/PolicyScopeSection.tsx b/ui/apps/platform/src/Containers/Policies/Detail/PolicyScopeSection.tsx index b25b665fc73f6..2c6ba1af8cbf9 100644 --- a/ui/apps/platform/src/Containers/Policies/Detail/PolicyScopeSection.tsx +++ b/ui/apps/platform/src/Containers/Policies/Detail/PolicyScopeSection.tsx @@ -21,7 +21,7 @@ function PolicyScopeSection({ scope, exclusions }: PolicyScopeSectionProps): Rea <> {scope?.length !== 0 && ( <> - Scope inclusions + Included resources {scope.map((restriction, index) => ( // eslint-disable-next-line react/no-array-index-key @@ -41,7 +41,7 @@ function PolicyScopeSection({ scope, exclusions }: PolicyScopeSectionProps): Rea )} {excludedDeploymentScopes?.length !== 0 && ( <> - Scope exclusions + Excluded resources {excludedDeploymentScopes.map((excludedDeployment, index) => ( // eslint-disable-next-line react/no-array-index-key diff --git a/ui/apps/platform/src/Containers/Policies/Wizard/PolicyWizard.tsx b/ui/apps/platform/src/Containers/Policies/Wizard/PolicyWizard.tsx index a42fb5fc35ec6..20124446d5022 100644 --- a/ui/apps/platform/src/Containers/Policies/Wizard/PolicyWizard.tsx +++ b/ui/apps/platform/src/Containers/Policies/Wizard/PolicyWizard.tsx @@ -24,7 +24,7 @@ import type { ExtendedPageAction } from 'utils/queryStringUtils'; import { POLICY_BEHAVIOR_ACTIONS_ID, POLICY_BEHAVIOR_ID, - POLICY_BEHAVIOR_SCOPE_ID, + POLICY_BEHAVIOR_RESOURCES_ID, POLICY_DEFINITION_DETAILS_ID, POLICY_DEFINITION_ID, POLICY_DEFINITION_LIFECYCLE_ID, @@ -227,9 +227,9 @@ function PolicyWizard({ pageAction, policy }: PolicyWizardProps): ReactElement { isExpandable steps={[ diff --git a/ui/apps/platform/src/Containers/Policies/Wizard/Step4/ExclusionScopeCard.tsx b/ui/apps/platform/src/Containers/Policies/Wizard/Step4/ExclusionScopeCard.tsx index 6f6b00fe235fc..96891af183dae 100644 --- a/ui/apps/platform/src/Containers/Policies/Wizard/Step4/ExclusionScopeCard.tsx +++ b/ui/apps/platform/src/Containers/Policies/Wizard/Step4/ExclusionScopeCard.tsx @@ -33,7 +33,7 @@ function ExclusionScopeCard({ })); return ( - +
diff --git a/ui/apps/platform/src/Containers/Policies/Wizard/Step4/InclusionScopeCard.tsx b/ui/apps/platform/src/Containers/Policies/Wizard/Step4/InclusionScopeCard.tsx index 16edc0504d558..55426e1cbb8b6 100644 --- a/ui/apps/platform/src/Containers/Policies/Wizard/Step4/InclusionScopeCard.tsx +++ b/ui/apps/platform/src/Containers/Policies/Wizard/Step4/InclusionScopeCard.tsx @@ -60,7 +60,7 @@ function InclusionScopeCard({ } return ( - + diff --git a/ui/apps/platform/src/Containers/Policies/Wizard/Step4/PolicyScopeCardLegacy.tsx b/ui/apps/platform/src/Containers/Policies/Wizard/Step4/PolicyScopeCardLegacy.tsx index 1028b358569df..474a491c902e2 100644 --- a/ui/apps/platform/src/Containers/Policies/Wizard/Step4/PolicyScopeCardLegacy.tsx +++ b/ui/apps/platform/src/Containers/Policies/Wizard/Step4/PolicyScopeCardLegacy.tsx @@ -111,7 +111,11 @@ function PolicyScopeCardLegacy({ variant="plain" className="pf-v6-u-mr-md" onClick={onDelete} - title={`Delete ${type} scope`} + title={ + type === 'inclusion' + ? 'Delete included resource' + : 'Delete excluded resource' + } /> ), @@ -120,7 +124,9 @@ function PolicyScopeCardLegacy({ }} className="pf-v6-u-p-0" > - {type} scope + + {type === 'inclusion' ? 'Included resource' : 'Excluded resource'} + diff --git a/ui/apps/platform/src/Containers/Policies/Wizard/Step4/PolicyScopeForm.tsx b/ui/apps/platform/src/Containers/Policies/Wizard/Step4/PolicyScopeForm.tsx index d9ddab3d8ce8d..5be2cf31c5aa0 100644 --- a/ui/apps/platform/src/Containers/Policies/Wizard/Step4/PolicyScopeForm.tsx +++ b/ui/apps/platform/src/Containers/Policies/Wizard/Step4/PolicyScopeForm.tsx @@ -34,11 +34,31 @@ import type { ClientPolicy } from 'types/policy.proto'; import type { ListImage } from 'types/image.proto'; import { getImages } from 'services/imageService'; +import ExternalLink from 'Components/PatternFly/IconText/ExternalLink'; + import { initialExcludedDeployment, initialScope } from '../../policies.utils'; import PolicyScopeCardLegacy from './PolicyScopeCardLegacy'; import InclusionScopeCard from './InclusionScopeCard'; import ExclusionScopeCard from './ExclusionScopeCard'; +function PolicyScopeRE2Description(): ReactElement { + return ( +
+ Every field except Cluster can use RE2 matching. Empty fields apply to all values (no + filter).{' '} + + + Learn how to use regex here + + +
+ ); +} + function PolicyScopeForm(): ReactElement { const [isExcludeImagesOpen, setIsExcludeImagesOpen] = useState(false); const [filterValue, setFilterValue] = useState(''); @@ -119,10 +139,9 @@ function PolicyScopeForm(): ReactElement { return ( - Scope + Resources
- Create scopes to restrict or exclude your policy from entities within your - environment. + Configure the resources to be applied to, or excluded from this policy.
@@ -131,19 +150,21 @@ function PolicyScopeForm(): ReactElement { className="pf-v6-u-mt-lg pf-v6-u-mx-lg" isInline variant="info" - title="The selected event source does not support scoping." + title="The selected event source does not support resource targeting." component="p" /> )} - Restrict by scope -
- Use Restrict by scope to enable this policy only for a specific cluster, - namespace, or deployment label. You can add multiple scopes and also use - regular expressions (RE2 syntax) for namespaces and deployment labels. -
+ + Included resources +
+ Define which clusters, namespaces, and deployments this policy + evaluates. If no inclusions are added, all resources are included. +
+ +
@@ -187,13 +208,15 @@ function PolicyScopeForm(): ReactElement { - Exclude by scope -
- Use Exclude by scope to exclude entities from your policy. This function - is only available for Deploy and Runtime lifecycle stages. You can add - multiple scopes and also use regular expressions (RE2 syntax) for - namespaces and deployment labels. -
+ + Excluded resources +
+ Excluded resources define what this policy will not evaluate. They + narrow the result of your inclusions (or all resources, if you added + none). +
+ +
diff --git a/ui/apps/platform/src/Containers/Policies/Wizard/policyValidationSchemas.ts b/ui/apps/platform/src/Containers/Policies/Wizard/policyValidationSchemas.ts index bc3f52c2e856b..26d8c5461c351 100644 --- a/ui/apps/platform/src/Containers/Policies/Wizard/policyValidationSchemas.ts +++ b/ui/apps/platform/src/Containers/Policies/Wizard/policyValidationSchemas.ts @@ -4,7 +4,7 @@ import type { ClientPolicy } from 'types/policy.proto'; import { POLICY_BEHAVIOR_ACTIONS_ID, - POLICY_BEHAVIOR_SCOPE_ID, + POLICY_BEHAVIOR_RESOURCES_ID, POLICY_DEFINITION_DETAILS_ID, POLICY_DEFINITION_LIFECYCLE_ID, POLICY_DEFINITION_RULES_ID, @@ -198,7 +198,7 @@ export const validationSchemaStep4: yup.ObjectSchema = yup.ob }) .test( 'scope-has-at-least-one-property', - 'Scope must have at least one property', + 'Each included resource must have at least one field populated', (scope) => Boolean( scope?.cluster.trim() || @@ -231,7 +231,7 @@ export const validationSchemaStep4: yup.ObjectSchema = yup.ob }) .test( 'excluded-scope-has-at-least-one-property', - 'Excluded scope must have at least one property', + 'Each excluded resource must have at least one field populated', (value) => Boolean( value?.name.trim() || @@ -273,7 +273,7 @@ export function getValidationSchema(stepId: number | string): yup.Schema { return validationSchemaStep2; case POLICY_DEFINITION_RULES_ID: return validationSchemaStep3; - case POLICY_BEHAVIOR_SCOPE_ID: + case POLICY_BEHAVIOR_RESOURCES_ID: return validationSchemaStep4; case POLICY_BEHAVIOR_ACTIONS_ID: return validationSchemaStep5; diff --git a/ui/apps/platform/src/Containers/Policies/policies.constants.ts b/ui/apps/platform/src/Containers/Policies/policies.constants.ts index 5fc5177f0f313..24527f68a7f0d 100644 --- a/ui/apps/platform/src/Containers/Policies/policies.constants.ts +++ b/ui/apps/platform/src/Containers/Policies/policies.constants.ts @@ -4,6 +4,6 @@ export const POLICY_DEFINITION_DETAILS_ID = 'policy-definition-details'; export const POLICY_DEFINITION_LIFECYCLE_ID = 'policy-definition-lifecycle'; export const POLICY_DEFINITION_RULES_ID = 'policy-definition-rules'; export const POLICY_BEHAVIOR_ID = 'policy-behavior'; -export const POLICY_BEHAVIOR_SCOPE_ID = 'policy-behavior-scope'; +export const POLICY_BEHAVIOR_RESOURCES_ID = 'policy-behavior-resources'; export const POLICY_BEHAVIOR_ACTIONS_ID = 'policy-behavior-actions'; export const POLICY_REVIEW_ID = 'policy-review';