@@ -9,7 +9,6 @@ import { Button, styled, SvgIconProps } from '@mui/material'
99import HearingIcon from '@mui/icons-material/Hearing'
1010
1111import { DormantIcon , DownIcon , LowerLayerDownIcon , UpIcon } from 'icons/operstates'
12- import { BridgeIcon , BridgeInternalIcon , DummyIcon , HardwareNicIcon , HardwareNicPFIcon , HardwareNicVFIcon , MacvlanIcon , MacvlanMasterIcon , NicIcon , OverlayIcon , TapIcon , TunIcon , VethIcon } from 'icons/nifs'
1312
1413import { AddressFamily , AddressFamilySet , GHOSTWIRE_LABEL_ROOT , NetworkInterface , nifId , orderAddresses , SRIOVRole } from 'models/gw'
1514import { OperationalState } from 'models/gw'
@@ -19,6 +18,7 @@ import { relationClassName } from 'utils/relclassname'
1918import { rgba } from 'utils/rgba'
2019import { TargetCapture } from 'components/targetcapture'
2120import { NifCheckbox } from 'components/nifcheckbox'
21+ import { NifIcon } from 'components/nificon'
2222
2323
2424// The outer span holding together an optional "hardware" NIC icon as well
@@ -174,33 +174,6 @@ const OperstateIndicator = styled('span')(({ theme }) => ({
174174 [ `&.${ OperationalState . Dormant . toLowerCase ( ) } ` ] : { color : theme . palette . operstate . dormant } ,
175175} ) )
176176
177- const nifSRIOVIcons = {
178- [ SRIOVRole . None ] : HardwareNicIcon ,
179- [ SRIOVRole . PF ] : HardwareNicPFIcon ,
180- [ SRIOVRole . VF ] : HardwareNicVFIcon ,
181- }
182-
183- // Known network interface type icons, indexed by the kind property of network
184- // interface objects (and directly taken from what Linux' RTNETLINK tells us).
185- const nifTypeIcons : { [ key : string ] : ( props : SvgIconProps ) => JSX . Element } = {
186- 'bridge' : BridgeIcon ,
187- 'dummy' : DummyIcon ,
188- 'macvlan' : MacvlanIcon ,
189- 'tap' : TapIcon ,
190- 'tun' : TunIcon ,
191- 'veth' : VethIcon ,
192- 'vxlan' : OverlayIcon ,
193- }
194-
195- const nifIcon = ( nif : NetworkInterface ) => {
196- if ( GHOSTWIRE_LABEL_ROOT + 'bridge/internal' in nif . labels ) {
197- return BridgeInternalIcon
198- }
199- return ( nif . tuntapDetails && nifTypeIcons [ nif . tuntapDetails . mode ] ) ||
200- ( nif . macvlans && MacvlanMasterIcon ) ||
201- nifTypeIcons [ nif . kind ] || NicIcon
202- }
203-
204177const operStateIcons : { [ key : string ] : ( props : SvgIconProps ) => JSX . Element } = {
205178 [ OperationalState . Unknown ] : UpIcon ,
206179 [ OperationalState . Dormant ] : DormantIcon ,
@@ -343,11 +316,10 @@ export const NifBadge = ({
343316 const alias = ( nif . alias && nif . alias !== "" ) && < > (~< span className = "alias" > { nif . alias } </ span > )</ >
344317 const vid = ( nif . vlanDetails ) && < > VID { nif . vlanDetails . vid } </ >
345318
346- const NifIcon = nifIcon ( nif )
347319 const OperstateIcon = operStateIcons [ nif . operstate ]
348320
349321 const content = < >
350- < NifIcon />
322+ < NifIcon nif = { nif } />
351323 < OperstateIndicator
352324 as = { OperstateIcon }
353325 className = { nif . operstate . toLowerCase ( ) }
@@ -434,8 +406,6 @@ export const NifBadge = ({
434406 }
435407 }
436408
437- const HWIcon = nifSRIOVIcons [ nif . sriovrole || SRIOVRole . None ]
438-
439409 // With lots of information prepared we can finally render the badge,
440410 // optionally wrapped into a tooltip with some detail information about
441411 // the network interface.
@@ -451,7 +421,7 @@ export const NifBadge = ({
451421 : < Capture className = "nifcaptureicon alignright" target = { nif } /> ) }
452422 { nif . isPhysical &&
453423 < HWNif className = "nifbagdeicon" >
454- < HWIcon />
424+ < NifIcon nif = { nif } considerPhysical />
455425 </ HWNif >
456426 }
457427 { nif . isPromiscuous &&
0 commit comments