Skip to content

Commit

Permalink
Chanes collapsed view host in networking configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ammont82 committed Nov 6, 2024
1 parent 7456a33 commit 520e99b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ export type HostSummaryProps = {
numInterfaces: number;
hostIdx: number;
hasError: boolean;
bondPrimaryInterface: string;
bondSecondaryInterface: string;
};

const getLabelCollapsedHost = (
macAddress: string,
mappingValue: string,
bondPrimaryInterface: string,
bondSecondaryInterface: string,
) => {
if (bondPrimaryInterface !== '' && bondSecondaryInterface !== '') {
return `${bondPrimaryInterface}/${bondSecondaryInterface} -> ${mappingValue}`;
} else {
return `${macAddress} -> ${mappingValue}`;
}
};

const HostSummary: React.FC<HostSummaryProps> = ({
Expand All @@ -26,6 +41,8 @@ const HostSummary: React.FC<HostSummaryProps> = ({
numInterfaces,
hasError,
hostIdx,
bondPrimaryInterface,
bondSecondaryInterface,
}) => {
return (
<>
Expand All @@ -49,10 +66,14 @@ const HostSummary: React.FC<HostSummaryProps> = ({
{!hasError && (
<>
<FlexItem>
<Label
variant="outline"
data-testid="first-mapping-label"
>{`${macAddress} -> ${mappingValue}`}</Label>{' '}
<Label variant="outline" data-testid="first-mapping-label">
{getLabelCollapsedHost(
macAddress,
mappingValue,
bondPrimaryInterface,
bondSecondaryInterface,
)}
</Label>{' '}
</FlexItem>
{numInterfaces > 1 && (
<FlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,17 @@ const getCollapsedHostComponent = (protocolType: StaticProtocolType) => {
(protocolVersion) => value.ips[protocolVersion],
);
const mapValue = ipAddresses.join(', ');

return (
<HostSummary
title="MAC to IP mapping"
title={value.useBond ? 'Bonds to IP mapping' : 'MAC to IP mapping'}
numInterfaces={1}
macAddress={value.macAddress}
mappingValue={mapValue}
hostIdx={hostIdx}
hasError={!!error}
bondPrimaryInterface={value.bondPrimaryInterface}
bondSecondaryInterface={value.bondSecondaryInterface}
/>
);
};
Expand Down

0 comments on commit 520e99b

Please sign in to comment.