-
Notifications
You must be signed in to change notification settings - Fork 399
upcoming: [UIE-9559, UIE-9560] - Introduce Network Load Balancer feature to CM #13068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f8735b9
5998c7e
c6440a5
edd0c48
a1e4a67
aa72ae2
8eefa8d
5ecab0b
2708ea0
9487aee
6f9bee6
eb9ed17
d9a4662
de0c3ab
3544d0e
527a2eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@linode/manager": Upcoming Features | ||
| --- | ||
|
|
||
| Implement feature flag and routing for NLB ([#13068](https://github.com/linode/manager/pull/13068)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ const options: { flag: keyof Flags; label: string }[] = [ | |
| { flag: 'linodeDiskEncryption', label: 'Linode Disk Encryption (LDE)' }, | ||
| { flag: 'linodeInterfaces', label: 'Linode Interfaces' }, | ||
| { flag: 'lkeEnterprise2', label: 'LKE-Enterprise' }, | ||
| { flag: 'networkLoadBalancer', label: 'Network Load Balancer' }, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we have networkLoadBalancers as plural everywhere for consistency?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this ( |
||
| { flag: 'nodebalancerIpv6', label: 'NodeBalancer Dual Stack (IPv6)' }, | ||
| { flag: 'nodebalancerVpc', label: 'NodeBalancer-VPC Integration' }, | ||
| { flag: 'objMultiCluster', label: 'OBJ Multi-Cluster' }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { Notice } from '@linode/ui'; | ||
| import * as React from 'react'; | ||
|
|
||
| import { LandingHeader } from 'src/components/LandingHeader'; | ||
|
|
||
| export const NetworkLoadBalancersLanding = () => { | ||
| return ( | ||
| <> | ||
| <LandingHeader | ||
| breadcrumbProps={{ | ||
| pathname: 'Network Load Balancer', | ||
| removeCrumbX: 1, | ||
| }} | ||
| spacingBottom={16} | ||
| title="Network Load Balancer" | ||
| /> | ||
| <Notice variant="info">Network Load Balancer is coming soon...</Notice> | ||
| </> | ||
| ); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { createLazyRoute } from '@tanstack/react-router'; | ||
|
|
||
| import { NetworkLoadBalancersLanding } from './NetworkLoadBalancersLanding'; | ||
|
|
||
| export const networkLoadBalancersLazyRoute = createLazyRoute( | ||
| '/netloadbalancers' | ||
| )({ | ||
| component: NetworkLoadBalancersLanding, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { renderHook, waitFor } from '@testing-library/react'; | ||
|
|
||
| import { accountFactory } from 'src/factories'; | ||
| import { http, HttpResponse, server } from 'src/mocks/testServer'; | ||
| import { wrapWithTheme } from 'src/utilities/testHelpers'; | ||
|
|
||
| import { useIsNetworkLoadBalancerEnabled } from './utils'; | ||
|
|
||
| describe('useIsNetworkLoadBalancerEnabled', () => { | ||
| it('returns true if the feature is enabled', async () => { | ||
| const options = { flags: { networkLoadBalancer: true } }; | ||
| const account = accountFactory.build({ | ||
| capabilities: ['Network LoadBalancer'], | ||
| }); | ||
|
|
||
| server.use( | ||
| http.get('*/v4*/account', () => { | ||
| return HttpResponse.json(account); | ||
| }) | ||
| ); | ||
|
|
||
| const { result } = renderHook(() => useIsNetworkLoadBalancerEnabled(), { | ||
| wrapper: (ui) => wrapWithTheme(ui, options), | ||
| }); | ||
|
|
||
| await waitFor(() => { | ||
| expect(result.current.isNetworkLoadBalancerEnabled).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| it('returns false if the feature is NOT enabled', async () => { | ||
| const options = { flags: { networkLoadBalancer: false } }; | ||
|
|
||
| const { result } = renderHook(() => useIsNetworkLoadBalancerEnabled(), { | ||
| wrapper: (ui) => wrapWithTheme(ui, options), | ||
| }); | ||
|
|
||
| await waitFor(() => { | ||
| expect(result.current.isNetworkLoadBalancerEnabled).toBe(false); | ||
| }); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { useAccount } from '@linode/queries'; | ||
| import { isFeatureEnabledV2 } from '@linode/utilities'; | ||
|
|
||
| import { useFlags } from 'src/hooks/useFlags'; | ||
|
|
||
| /** | ||
| * | ||
| * @returns an object that contains boolean property to check whether Network LoadBalancer is enabled or not | ||
| */ | ||
| export const useIsNetworkLoadBalancerEnabled = (): { | ||
| isNetworkLoadBalancerEnabled: boolean; | ||
| } => { | ||
| const { data: account } = useAccount(); | ||
| const flags = useFlags(); | ||
|
|
||
| if (!flags) { | ||
| return { isNetworkLoadBalancerEnabled: false }; | ||
| } | ||
|
|
||
| const isNetworkLoadBalancerEnabled = isFeatureEnabledV2( | ||
| 'Network LoadBalancer', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be 'Network LoadBalancers' since we are referring to the capabilities API
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| Boolean(flags.networkLoadBalancer), | ||
| account?.capabilities ?? [] | ||
| ); | ||
|
|
||
| return { isNetworkLoadBalancerEnabled }; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { createRoute } from '@tanstack/react-router'; | ||
|
|
||
| import { rootRoute } from '../root'; | ||
| import { NetworkLoadBalancersRoute } from './networkLoadBalancersRoute'; | ||
|
|
||
| const networkLoadBalancersRoute = createRoute({ | ||
| component: NetworkLoadBalancersRoute, | ||
| getParentRoute: () => rootRoute, | ||
| path: 'netloadbalancers', | ||
| }); | ||
|
|
||
| const networkLoadBalancersIndexRoute = createRoute({ | ||
| getParentRoute: () => networkLoadBalancersRoute, | ||
| path: '/', | ||
| }).lazy(() => | ||
| import( | ||
| 'src/features/NetworkLoadBalancers/networkLoadBalancersLazyRoute' | ||
| ).then((m) => m.networkLoadBalancersLazyRoute) | ||
| ); | ||
|
|
||
| export const networkLoadBalancersRouteTree = | ||
| networkLoadBalancersRoute.addChildren([networkLoadBalancersIndexRoute]); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { NotFound } from '@linode/ui'; | ||
| import { Outlet } from '@tanstack/react-router'; | ||
| import React from 'react'; | ||
|
|
||
| import { ProductInformationBanner } from 'src/components/ProductInformationBanner/ProductInformationBanner'; | ||
| import { SuspenseLoader } from 'src/components/SuspenseLoader'; | ||
| import { useIsNetworkLoadBalancerEnabled } from 'src/features/NetworkLoadBalancers/utils'; | ||
|
|
||
| export const NetworkLoadBalancersRoute = () => { | ||
| const { isNetworkLoadBalancerEnabled } = useIsNetworkLoadBalancerEnabled(); | ||
|
|
||
| if (!isNetworkLoadBalancerEnabled) { | ||
| return <NotFound />; | ||
| } | ||
| return ( | ||
| <React.Suspense fallback={<SuspenseLoader />}> | ||
| <ProductInformationBanner bannerLocation="Network LoadBalancers" /> | ||
| <Outlet /> | ||
| </React.Suspense> | ||
| ); | ||
| }; |

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a corresponding test case for this functionality?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in edd0c48