Skip to content

Commit 8c152e3

Browse files
fix: [UIE-9888] - update node balancer type for enterprise and remove duplicate nodebalancer rows in VPC subnet table (#13472)
1 parent 0bb4f89 commit 8c152e3

7 files changed

Lines changed: 26 additions & 9 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/api-v4": Changed
3+
---
4+
5+
Update node balancer type for enterprise from premium_40GB to premium_40gb ([#13472](https://github.com/linode/manager/pull/13472))

packages/api-v4/src/nodebalancers/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type UDPStickiness = 'none' | 'session' | 'source_ip';
1010

1111
export type Stickiness = TCPStickiness | UDPStickiness;
1212

13-
type NodeBalancerType = 'common' | 'premium' | 'premium_40GB';
13+
type NodeBalancerType = 'common' | 'premium' | 'premium_40gb';
1414

1515
export interface LKEClusterInfo {
1616
id: number;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Fixed
3+
---
4+
5+
Update node balancer type for enterprise and remove duplicate nodebalancer rows in VPC subnet table ([#13472](https://github.com/linode/manager/pull/13472))

packages/manager/src/features/NodeBalancers/NodeBalancerDetail/NodeBalancerSummary/SummaryPanel.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ describe('SummaryPanel', () => {
162162
expect(typeElement).toBeVisible();
163163
});
164164

165-
it('displays type: Enterprise if the nodebalancer is premium_40GB', () => {
165+
it('displays type: Enterprise if the nodebalancer is premium_40gb', () => {
166166
queryMocks.useNodeBalancerQuery.mockReturnValue({
167-
data: nodeBalancerFactory.build({ type: 'premium_40GB' }),
167+
data: nodeBalancerFactory.build({ type: 'premium_40gb' }),
168168
});
169169

170170
const { getByText } = renderWithTheme(<SummaryPanel />);

packages/manager/src/features/NodeBalancers/NodeBalancerDetail/NodeBalancerSummary/SummaryPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export const SummaryPanel = () => {
112112
<strong>Type: </strong>
113113
{nodebalancer.type === 'common' && 'Basic'}
114114
{nodebalancer.type === 'premium' && 'Premium'}
115-
{nodebalancer.type === 'premium_40GB' && 'Enterprise'}
115+
{nodebalancer.type === 'premium_40gb' && 'Enterprise'}
116116
</Typography>
117117
</StyledSection>
118118
<StyledSection>

packages/manager/src/features/VPCs/VPCDetail/VPCSubnetsTable.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,13 @@ export const VPCSubnetsTable = (props: Props) => {
315315

316316
const getTableItems = (): TableItem[] => {
317317
return subnets.data.map((subnet) => {
318+
// NodeBalancers can have same VPC subnet as its frontend and backend configuration.
319+
// and this can create duplicate entries in the resources count and also in the list of nodebalancers assigned to a subnet.
320+
// To avoid this, we are creating a unique list of nodebalancers based on their id.
321+
const uniqueNodebalancers = Array.from(
322+
new Map(subnet.nodebalancers.map((nb) => [nb.id, nb])).values()
323+
);
324+
318325
const OuterTableCells = (
319326
<>
320327
<Hidden smDown>
@@ -326,7 +333,7 @@ export const VPCSubnetsTable = (props: Props) => {
326333
)}
327334
<Hidden smDown>
328335
<TableCell>
329-
{`${isNodebalancerVPCEnabled ? subnet.linodes.length + subnet.nodebalancers.length : subnet.linodes.length}`}
336+
{`${isNodebalancerVPCEnabled ? subnet.linodes.length + uniqueNodebalancers.length : subnet.linodes.length}`}
330337
</TableCell>
331338
</Hidden>
332339
<TableCell actionCell>
@@ -336,7 +343,7 @@ export const VPCSubnetsTable = (props: Props) => {
336343
handleEdit={handleSubnetEdit}
337344
handleUnassignLinodes={handleSubnetUnassignLinodes}
338345
numLinodes={subnet.linodes.length}
339-
numNodebalancers={subnet.nodebalancers.length}
346+
numNodebalancers={uniqueNodebalancers.length}
340347
subnet={subnet}
341348
vpcId={vpcId}
342349
/>
@@ -376,7 +383,7 @@ export const VPCSubnetsTable = (props: Props) => {
376383
)}
377384
</TableBody>
378385
</Table>
379-
{isNodebalancerVPCEnabled && subnet.nodebalancers?.length > 0 && (
386+
{isNodebalancerVPCEnabled && uniqueNodebalancers.length > 0 && (
380387
<Table aria-label="NodeBalancers" size="small" striped={false}>
381388
<TableHead
382389
style={{
@@ -386,7 +393,7 @@ export const VPCSubnetsTable = (props: Props) => {
386393
{SubnetNodebalancerTableRowHead}
387394
</TableHead>
388395
<TableBody>
389-
{subnet.nodebalancers.map((nb) => (
396+
{uniqueNodebalancers.map((nb) => (
390397
<SubnetNodeBalancerRow
391398
key={nb.id}
392399
nodeBalancerId={nb.id}

packages/utilities/src/factories/nodebalancer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const nodeBalancerFactory = Factory.Sync.makeFactory<NodeBalancer>({
4747
}),
4848
type: Factory.each((i) => {
4949
if (i === 1) {
50-
return 'premium_40GB';
50+
return 'premium_40gb';
5151
}
5252
if (i % 2 === 0) {
5353
return 'premium';

0 commit comments

Comments
 (0)