diff --git a/ui/apps/platform/src/Containers/Policies/PatternFly/PolicyPage.tsx b/ui/apps/platform/src/Containers/Policies/PatternFly/PolicyPage.tsx index 6a562a1611284..64353f3194161 100644 --- a/ui/apps/platform/src/Containers/Policies/PatternFly/PolicyPage.tsx +++ b/ui/apps/platform/src/Containers/Policies/PatternFly/PolicyPage.tsx @@ -56,6 +56,7 @@ const initialPolicy: Policy = { SORT_lifecycleStage: '', // For internal use only. SORT_enforcement: false, // For internal use only. policyVersion: '', + serverPolicySections: [], policySections: [ { sectionName: 'Policy Section 1', diff --git a/ui/apps/platform/src/Containers/Policies/PatternFly/policies.utils.ts b/ui/apps/platform/src/Containers/Policies/PatternFly/policies.utils.ts index 171a7748f4257..619ba87460a48 100644 --- a/ui/apps/platform/src/Containers/Policies/PatternFly/policies.utils.ts +++ b/ui/apps/platform/src/Containers/Policies/PatternFly/policies.utils.ts @@ -381,6 +381,7 @@ function preFormatNestedPolicyFields(policy: Policy): Policy { } const clientPolicy = cloneDeep(policy); + clientPolicy.serverPolicySections = policy.policySections; // itreating through each value in a policy group in a policy section to parse value string policy.policySections.forEach((policySection, sectionIdx) => { const { policyGroups } = policySection; @@ -420,21 +421,30 @@ function postFormatNestedPolicyFields(policy: Policy): Policy { } const serverPolicy = cloneDeep(policy); - // itereating through each value in a policy group in a policy section to format to a flat value string - policy.policySections.forEach((policySection, sectionIdx) => { - const { policyGroups } = policySection; - policyGroups.forEach((policyGroup, groupIdx) => { - const { values } = policyGroup; - values.forEach((value, valueIdx) => { - serverPolicy.policySections[sectionIdx].policyGroups[groupIdx].values[valueIdx] = { - value: formatValueStr(value as ValueObj, policyGroup.fieldName), - }; + if (policy.criteriaLocked) { + serverPolicy.policySections = policy.serverPolicySections; + } else { + // itereating through each value in a policy group in a policy section to format to a flat value string + policy.policySections.forEach((policySection, sectionIdx) => { + const { policyGroups } = policySection; + policyGroups.forEach((policyGroup, groupIdx) => { + const { values } = policyGroup; + values.forEach((value, valueIdx) => { + serverPolicy.policySections[sectionIdx].policyGroups[groupIdx].values[ + valueIdx + ] = { + value: formatValueStr(value as ValueObj, policyGroup.fieldName), + }; + }); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + delete serverPolicy.policySections[sectionIdx].policyGroups[groupIdx].fieldKey; }); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - delete serverPolicy.policySections[sectionIdx].policyGroups[groupIdx].fieldKey; }); - }); + } + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + delete serverPolicy.serverPolicySections; return serverPolicy; } diff --git a/ui/apps/platform/src/Containers/Policies/Wizard/Form/descriptors.tsx b/ui/apps/platform/src/Containers/Policies/Wizard/Form/descriptors.tsx index a491ae35ed196..dbf8950aae587 100644 --- a/ui/apps/platform/src/Containers/Policies/Wizard/Form/descriptors.tsx +++ b/ui/apps/platform/src/Containers/Policies/Wizard/Form/descriptors.tsx @@ -661,7 +661,7 @@ export const policyConfigurationDescriptor: Descriptor[] = [ shortName: 'Exposed node port', negatedName: `Exposed node port doesn't match`, category: policyCriteriaCategories.NETWORKING, - type: 'number', + type: 'text', placeholder: '22', canBooleanLogic: true, }, diff --git a/ui/apps/platform/src/Containers/Violations/Details/ViolationDetailsPage.tsx b/ui/apps/platform/src/Containers/Violations/Details/ViolationDetailsPage.tsx index 490a6856a630e..fd26a5c3903e6 100644 --- a/ui/apps/platform/src/Containers/Violations/Details/ViolationDetailsPage.tsx +++ b/ui/apps/platform/src/Containers/Violations/Details/ViolationDetailsPage.tsx @@ -12,12 +12,9 @@ import { } from '@patternfly/react-core'; import { fetchAlert } from 'services/AlertsService'; -import { preFormatPolicyFields } from 'Containers/Policies/Wizard/Form/utils'; -import useFeatureFlagEnabled from 'hooks/useFeatureFlagEnabled'; -import { knownBackendFlags } from 'utils/featureFlags'; import PolicyDetailContent from '../../Policies/PatternFly/Detail/PolicyDetailContent'; +import { getClientWizardPolicy } from '../../Policies/PatternFly/policies.utils'; import DeploymentDetails from './DeploymentDetails'; -import PolicyDetails from './PolicyDetails'; import EnforcementDetails from './EnforcementDetails'; import { Alert } from '../types/violationTypes'; import ViolationNotFoundPage from '../ViolationNotFoundPage'; @@ -30,7 +27,6 @@ function ViolationDetailsPage(): ReactElement { const [isFetchingSelectedAlert, setIsFetchingSelectedAlert] = useState(false); const { alertId } = useParams(); - const isPoliciesPFEnabled = useFeatureFlagEnabled(knownBackendFlags.ROX_POLICIES_PATTERNFLY); function handleTabClick(_, tabIndex) { setActiveTabKey(tabIndex); @@ -111,17 +107,13 @@ function ViolationDetailsPage(): ReactElement { )} Policy}> - {isPoliciesPFEnabled ? ( - <> - - Policy overview - - - - - ) : ( - - )} + <> + + Policy overview + + + + diff --git a/ui/apps/platform/src/types/policy.proto.ts b/ui/apps/platform/src/types/policy.proto.ts index a4fa506a14318..79d3fe615d0d4 100644 --- a/ui/apps/platform/src/types/policy.proto.ts +++ b/ui/apps/platform/src/types/policy.proto.ts @@ -40,6 +40,7 @@ export type Policy = { SORT_lifecycleStage: string; // For internal use only. SORT_enforcement: boolean; // For internal use only. policyVersion: string; + serverPolicySections: PolicySection[]; // For internal use only. policySections: PolicySection[]; mitreAttackVectors: PolicyMitreAttackVector[]; readonly criteriaLocked: boolean; // If true, the policy's criteria fields are rendered read-only.