Skip to content

Commit

Permalink
Merge pull request #2155 from avivtur/pod-networking-turns-to-bridge-…
Browse files Browse the repository at this point in the history
…on-edit

CNV-47511: Editing NIC in UI uses wrong binding and does not allow changing MAC
  • Loading branch information
openshift-merge-bot[bot] authored Sep 4, 2024
2 parents 09ad988 + 1c9ff8d commit 31e4583
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import NetworkInterfaceMACAddressInput from './components/NetworkInterfaceMacAdd
import NetworkInterfaceModelSelect from './components/NetworkInterfaceModelSelect';
import NetworkInterfaceNetworkSelect from './components/NetworkInterfaceNetworkSelect/NetworkInterfaceNetworkSelect';
import { interfaceModelType } from './utils/constants';
import { getNetworkName, networkNameStartWithPod, podNetworkExists } from './utils/helpers';
import { getNetworkName, podNetworkExists } from './utils/helpers';

import './NetworkInterfaceModal.scss';

Expand Down Expand Up @@ -104,6 +104,7 @@ const NetworkInterfaceModal: FC<NetworkInterfaceModalProps> = ({
setInterfaceModel={setInterfaceModel}
/>
<NetworkInterfaceNetworkSelect
iface={iface}
interfaceType={interfaceType}
isEditing={Boolean(network) && Boolean(iface)}
namespace={namespace}
Expand All @@ -121,7 +122,7 @@ const NetworkInterfaceModal: FC<NetworkInterfaceModalProps> = ({
>
<NetworkInterfaceMACAddressInput
interfaceMACAddress={interfaceMACAddress}
isDisabled={!networkName || networkNameStartWithPod(networkName)}
isDisabled={!networkName}
setInterfaceMACAddress={setInterfaceMACAddress}
setIsError={setSubmitDisabled}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { Dispatch, FC, MouseEvent, SetStateAction, useEffect, useMemo } from 'react';

import { V1VirtualMachine } from '@kubevirt-ui/kubevirt-api/kubevirt';
import { V1Interface, V1VirtualMachine } from '@kubevirt-ui/kubevirt-api/kubevirt';
import FormGroupHelperText from '@kubevirt-utils/components/FormGroupHelperText/FormGroupHelperText';
import FormPFSelect from '@kubevirt-utils/components/FormPFSelect/FormPFSelect';
import Loading from '@kubevirt-utils/components/Loading/Loading';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import { interfacesTypes } from '@kubevirt-utils/resources/vm/utils/network/constants';
import { getNetworkInterfaceType } from '@kubevirt-utils/resources/vm/utils/network/selectors';
import {
FormGroup,
Label,
Expand All @@ -21,6 +22,7 @@ import NetworkSelectHelperPopover from './components/NetworkSelectHelperPopover/

type NetworkInterfaceNetworkSelectProps = {
editInitValueNetworkName?: string | undefined;
iface: V1Interface;
interfaceType: string;
isEditing?: boolean | undefined;
namespace?: string;
Expand All @@ -33,6 +35,7 @@ type NetworkInterfaceNetworkSelectProps = {

const NetworkInterfaceNetworkSelect: FC<NetworkInterfaceNetworkSelectProps> = ({
editInitValueNetworkName,
iface,
interfaceType,
isEditing,
namespace,
Expand Down Expand Up @@ -80,12 +83,12 @@ const NetworkInterfaceNetworkSelect: FC<NetworkInterfaceNetworkSelectProps> = ({
useEffect(() => {
if (!loaded) return;

const initialInterfaceType = getNadType(nads?.[0]);
const initialInterfaceType = interfacesTypes[getNetworkInterfaceType(iface)];

if (!initialInterfaceType) return;

setInterfaceType(initialInterfaceType);
}, [loaded, nads, setInterfaceType]);
}, [loaded, nads, setInterfaceType, iface]);

const validated =
canCreateNetworkInterface || isEditing ? ValidatedOptions.default : ValidatedOptions.error;
Expand Down

0 comments on commit 31e4583

Please sign in to comment.