diff --git a/packages/orchestrator-ui-components/src/components/WfoForms/formFields/deprecated/IpNetworkField.tsx b/packages/orchestrator-ui-components/src/components/WfoForms/formFields/deprecated/IpNetworkField.tsx index 56bd2a221..7fd3a3f2a 100644 --- a/packages/orchestrator-ui-components/src/components/WfoForms/formFields/deprecated/IpNetworkField.tsx +++ b/packages/orchestrator-ui-components/src/components/WfoForms/formFields/deprecated/IpNetworkField.tsx @@ -14,18 +14,15 @@ */ import React, { useState } from 'react'; -import { useTranslations } from 'next-intl'; import { connectField, filterDOMProps } from 'uniforms'; -import { EuiCallOut, EuiFormRow, EuiText } from '@elastic/eui'; +import { EuiFormRow, EuiText } from '@elastic/eui'; import { getCommonFormFieldStyles } from '@/components/WfoForms/formFields/commonStyles'; import SplitPrefix from '@/components/WfoForms/formFields/deprecated/SplitPrefix'; import { useWithOrchestratorTheme } from '@/hooks'; import { FieldProps } from '../types'; -import IpPrefixTableField from './IpPrefixTableField'; -import { IpBlock } from './types'; export type IPvAnyNetworkFieldProps = FieldProps< string, @@ -48,17 +45,16 @@ function IpNetwork({ }: IPvAnyNetworkFieldProps) { const { formRowStyle } = useWithOrchestratorTheme(getCommonFormFieldStyles); - const t = useTranslations('pydanticForms'); - const [selectedPrefix, setSelectedPrefix] = useState( - undefined, - ); - const [manualOverride, setManualOverride] = useState(false); + const [selectedPrefix] = useState(value); - const usePrefix = selectedPrefix?.prefix ?? value; + const usePrefix = selectedPrefix; const [subnet, netmask] = usePrefix?.split('/') ?? ['', '']; - const usedPrefixMin = - prefixMin ?? - parseInt(netmask, 10) + (selectedPrefix?.state === 0 ? 0 : 1); + + let usedPrefixMin = prefixMin ?? parseInt(netmask, 10); + + if (usedPrefixMin < 32) { + usedPrefixMin += 1; + } return (
@@ -73,32 +69,7 @@ function IpNetwork({ >
- {!prefixMin && ( - { - if (!readOnly) { - if ( - prefix.state === 0 || - prefix.state === 1 - ) { - setSelectedPrefix(prefix); - } - setManualOverride(false); - onChange(prefix.prefix); - } - }} - onManualOverride={(prefixString: string) => { - if (!readOnly) { - setManualOverride(true); - onChange(prefixString); - } - }} - selected_prefix_id={selectedPrefix?.id} - /> - )} - {usePrefix && !manualOverride && ( + {usePrefix && ( )} - {usePrefix && manualOverride && ( - -

{value}

-
- )}