Skip to content

Commit 4b26ac6

Browse files
fix: [UIE-9841] - Hide dual stack option if no IPv6 prefixes available in create VPC flow
1 parent 426427c commit 4b26ac6

File tree

9 files changed

+95
-65
lines changed

9 files changed

+95
-65
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/api-v4": Tech Stories
3+
---
4+
5+
Clean up unused VPC IPv6 Large Prefixes tag ([#13245](https://github.com/linode/manager/pull/13245))

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ export const accountCapabilities = [
9393
'Vlans',
9494
'VPCs',
9595
'VPC Dual Stack',
96-
'VPC IPv6 Large Prefixes',
9796
] as const;
9897

9998
export type AccountCapability = (typeof accountCapabilities)[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+
Hide dual stack option if no IPv6 prefixes available in create VPC flow ([#13245](https://github.com/linode/manager/pull/13245))

packages/manager/src/factories/account.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const accountFactory = Factory.Sync.makeFactory<Account>({
5656
'Placement Group',
5757
'Vlans',
5858
'Kubernetes Enterprise',
59+
'VPC Dual Stack',
5960
],
6061
city: 'Philadelphia',
6162
company: Factory.each((i) => `company-${i}`),

packages/manager/src/factories/userAccountPermissions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import type { PermissionType } from '@linode/api-v4';
33
export const userAccountPermissionsFactory: PermissionType[] = [
44
'create_linode',
55
'create_firewall',
6+
'create_vpc',
67
];

packages/manager/src/features/VPCs/VPCCreate/FormComponents/VPCTopSectionContent.test.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,11 @@ describe('VPC Top Section form content', () => {
7373

7474
const NetworkingIPStackRadios = screen.getAllByRole('radio');
7575
expect(NetworkingIPStackRadios[0]).toBeChecked(); // IPv4
76-
expect(NetworkingIPStackRadios[1]).not.toBeChecked(); // Dual Stack
7776
});
7877

7978
it('renders VPC IPv6 Prefix Length options with /52 selected if the selected region has multiple prefix lengths available', async () => {
8079
const account = accountFactory.build({
81-
capabilities: ['VPC Dual Stack', 'VPC IPv6 Large Prefixes'],
80+
capabilities: ['VPC Dual Stack'],
8281
});
8382

8483
server.use(http.get('*/account', () => HttpResponse.json(account)));
@@ -148,7 +147,7 @@ describe('VPC Top Section form content', () => {
148147
expect(IPv6CIDRRadios[3]).toBeChecked(); // /52
149148
});
150149

151-
it('does not render VPC IPv6 Prefix Length options if there are none available or only /52 available', async () => {
150+
it('does not show dual stack option and does not render VPC IPv6 Prefix Length options if there are none available or only /52 available', async () => {
152151
const account = accountFactory.build({
153152
capabilities: ['VPC Dual Stack'],
154153
});
@@ -189,10 +188,10 @@ describe('VPC Top Section form content', () => {
189188
expect(screen.getByText('IP Stack')).toBeVisible();
190189
});
191190

192-
const NetworkingIPStackRadios = screen.getAllByRole('radio');
193-
await userEvent.click(NetworkingIPStackRadios[1]);
194-
expect(NetworkingIPStackRadios[0]).not.toBeChecked(); // IPv4
195-
expect(NetworkingIPStackRadios[1]).toBeChecked(); // Dual Stack
191+
expect(screen.getByText('IPv4')).toBeVisible(); // IPv4
192+
expect(
193+
screen.queryByText('IPv4 + IPv6 (Dual Stack)')
194+
).not.toBeInTheDocument(); // Dual Stack
196195

197196
expect(
198197
screen.queryByText('VPC IPv6 Prefix Length')

packages/manager/src/features/VPCs/VPCCreate/FormComponents/VPCTopSectionContent.tsx

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -205,61 +205,64 @@ export const VPCTopSectionContent = (props: Props) => {
205205
sxCardBase={{ gap: 0 }}
206206
sxCardBaseIcon={{ svg: { fontSize: '20px' } }}
207207
/>
208-
<SelectionCard
209-
checked={isDualStackSelected}
210-
disabled={!permissions?.create_vpc}
211-
gridSize={{
212-
md: isDrawer ? 12 : 3,
213-
sm: 12,
214-
xs: 12,
215-
}}
216-
heading="IPv4 + IPv6 (Dual Stack)"
217-
onClick={() => {
218-
field.onChange([
219-
{
220-
range: '/52',
221-
},
222-
]);
223-
subnets?.forEach((subnet, idx) =>
224-
update(idx, {
225-
...subnet,
226-
ipv6: subnet.ipv6 ?? [{ range: '/56' }],
227-
})
228-
);
229-
}}
230-
renderIcon={() => (
231-
<Radio
208+
{availableRegionIPv6PrefixLengths &&
209+
availableRegionIPv6PrefixLengths.length > 1 && (
210+
<SelectionCard
232211
checked={isDualStackSelected}
233212
disabled={!permissions?.create_vpc}
234-
/>
235-
)}
236-
renderVariant={() => (
237-
<TooltipIcon
238-
status="info"
239-
sxTooltipIcon={{
240-
padding: '8px',
213+
gridSize={{
214+
md: isDrawer ? 12 : 3,
215+
sm: 12,
216+
xs: 12,
241217
}}
242-
text={
243-
<Stack spacing={2}>
244-
<Typography>
245-
The VPC supports both IPv4 and IPv6 addresses.
246-
</Typography>
247-
<Typography>
248-
For IPv4, {RFC1918HelperText}
249-
</Typography>
250-
<Typography>
251-
For IPv6, the VPC is assigned an IPv6 prefix
252-
length of <Code>/52</Code> by default.
253-
</Typography>
254-
</Stack>
255-
}
256-
width={250}
218+
heading="IPv4 + IPv6 (Dual Stack)"
219+
onClick={() => {
220+
field.onChange([
221+
{
222+
range: '/52',
223+
},
224+
]);
225+
subnets?.forEach((subnet, idx) =>
226+
update(idx, {
227+
...subnet,
228+
ipv6: subnet.ipv6 ?? [{ range: '/56' }],
229+
})
230+
);
231+
}}
232+
renderIcon={() => (
233+
<Radio
234+
checked={isDualStackSelected}
235+
disabled={!permissions?.create_vpc}
236+
/>
237+
)}
238+
renderVariant={() => (
239+
<TooltipIcon
240+
status="info"
241+
sxTooltipIcon={{
242+
padding: '8px',
243+
}}
244+
text={
245+
<Stack spacing={2}>
246+
<Typography>
247+
The VPC supports both IPv4 and IPv6 addresses.
248+
</Typography>
249+
<Typography>
250+
For IPv4, {RFC1918HelperText}
251+
</Typography>
252+
<Typography>
253+
For IPv6, the VPC is assigned an IPv6 prefix
254+
length of <Code>/52</Code> by default.
255+
</Typography>
256+
</Stack>
257+
}
258+
width={250}
259+
/>
260+
)}
261+
subheadings={[]}
262+
sxCardBase={{ gap: 0 }}
263+
sxCardBaseIcon={{ svg: { fontSize: '20px' } }}
257264
/>
258265
)}
259-
subheadings={[]}
260-
sxCardBase={{ gap: 0 }}
261-
sxCardBaseIcon={{ svg: { fontSize: '20px' } }}
262-
/>
263266
</Grid>
264267
</RadioGroup>
265268
)}

packages/manager/src/hooks/useVPCDualStack.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ export const useVPCDualStack = (ipv6?: VPCIPv6[]) => {
1717
account?.capabilities ?? []
1818
);
1919

20-
const isEnterpriseCustomer = isFeatureEnabledV2(
21-
'VPC IPv6 Large Prefixes',
22-
Boolean(flags.vpcIpv6),
23-
account?.capabilities ?? []
24-
);
25-
2620
const shouldDisplayIPv6 = isDualStackEnabled && isDualStackSelected;
2721
const recommendedIPv6 = shouldDisplayIPv6
2822
? [
@@ -35,7 +29,6 @@ export const useVPCDualStack = (ipv6?: VPCIPv6[]) => {
3529
return {
3630
isDualStackEnabled,
3731
isDualStackSelected,
38-
isEnterpriseCustomer,
3932
shouldDisplayIPv6,
4033
recommendedIPv6,
4134
};

packages/manager/src/mocks/serverHandlers.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,30 @@ const vpc = [
521521
const subnet = subnetFactory.build({ ...(body as any) });
522522
return HttpResponse.json(subnet);
523523
}),
524+
http.get('*/v4beta/regions/vpc-availability', () => {
525+
return HttpResponse.json({
526+
data: [
527+
{
528+
region: 'ap-west',
529+
available: false,
530+
available_ipv6_prefix_lengths: [],
531+
},
532+
{
533+
region: 'in-maa',
534+
available: true,
535+
available_ipv6_prefix_lengths: [52],
536+
},
537+
{
538+
region: 'us-southeast',
539+
available: true,
540+
available_ipv6_prefix_lengths: [48, 52],
541+
},
542+
],
543+
page: 1,
544+
pages: 1,
545+
results: 3,
546+
});
547+
}),
524548
];
525549

526550
const iam = [

0 commit comments

Comments
 (0)