Skip to content

Commit

Permalink
When 'Use bond' is check we shouldn't have the extra mac-address field
Browse files Browse the repository at this point in the history
  • Loading branch information
ammont82 committed Nov 4, 2024
1 parent f54ba46 commit ecc396a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const getExpandedHostComponent = (protocolType: StaticProtocolType) => {
name={`${fieldName}.useBond`}
/>
</FormGroup>
{useBond && (
{useBond.value && (
<Grid hasGutter className="pf-v5-u-ml-lg">
<FormGroup fieldId={`bond-type-${hostIdx}`}>
<BondsSelect name={`${fieldName}.bondType`} data-testid={`bond-type-${hostIdx}`} />
Expand All @@ -81,12 +81,14 @@ const getExpandedHostComponent = (protocolType: StaticProtocolType) => {
/>
</Grid>
)}
<OcmInputField
name={`${fieldName}.macAddress`}
label="MAC Address"
isRequired
data-testid={`mac-address-${hostIdx}`}
/>
{!useBond.value && (
<OcmInputField
name={`${fieldName}.macAddress`}
label="MAC Address"
isRequired
data-testid={`mac-address-${hostIdx}`}
/>
)}
{getShownProtocolVersions(protocolType).map((protocolVersion) => (
<FormGroup
label={`IP address (${getProtocolVersionLabel(protocolVersion)})`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ const getAllBondInterfaces: UniqueStringArrayExtractor<FormViewHostsValues> = (

const getHostValidationSchema = (networkWideValues: FormViewNetworkWideValues) =>
Yup.object({
macAddress: macAddressValidationSchema
.required(requiredMsg)
.concat(getUniqueValidationSchema(getAllMacAddresses)),
macAddress: Yup.mixed().when('useBond', {
is: false,
then: () =>
macAddressValidationSchema
.required(requiredMsg)
.concat(getUniqueValidationSchema(getAllMacAddresses)),
otherwise: () => Yup.mixed().notRequired(),
}),
ips: Yup.object({
ipv4: showIpv4(networkWideValues.protocolType)
? getInMachineNetworkValidationSchema(
Expand Down

0 comments on commit ecc396a

Please sign in to comment.