-
Notifications
You must be signed in to change notification settings - Fork 401
upcoming: [UIE-10690, UIE-10691] β Create new Summary section in the NodeBalancer Details tab #13563
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
Open
harsh-akamai
wants to merge
4
commits into
linode:develop
Choose a base branch
from
harsh-akamai:aclp-nb-integration-feature-flag
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
upcoming: [UIE-10690, UIE-10691] β Create new Summary section in the NodeBalancer Details tab #13563
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3589578
upcoming: [UIE-10690] β Support ACLP-NB Metrics Integration feature flag
harsh-akamai d8b9798
summary section revamp
harsh-akamai f7350fa
Merge branch 'develop' into aclp-nb-integration-feature-flag
harsh-akamai e326c70
Merge branch 'develop' into aclp-nb-integration-feature-flag
tvijay-akamai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ import { | |||||
| useNodeBalancerQuery, | ||||||
| useNodebalancerUpdateMutation, | ||||||
| } from '@linode/queries'; | ||||||
| import { CircleProgress, ErrorState, Notice } from '@linode/ui'; | ||||||
| import { CircleProgress, ErrorState, NewFeatureChip, Notice } from '@linode/ui'; | ||||||
| import { useParams } from '@tanstack/react-router'; | ||||||
| import React from 'react'; | ||||||
|
|
||||||
|
|
@@ -13,12 +13,14 @@ import { TabPanels } from 'src/components/Tabs/TabPanels'; | |||||
| import { Tabs } from 'src/components/Tabs/Tabs'; | ||||||
| import { TanStackTabLinkList } from 'src/components/Tabs/TanStackTabLinkList'; | ||||||
| import { usePermissions } from 'src/features/IAM/hooks/usePermissions'; | ||||||
| import { useFlags } from 'src/hooks/useFlags'; | ||||||
| import { useTabs } from 'src/hooks/useTabs'; | ||||||
| import { getErrorMap } from 'src/utilities/errorUtils'; | ||||||
|
|
||||||
| import { NodeBalancerConfigurationsWrapper } from './NodeBalancerConfigurationsWrapper'; | ||||||
| import { NodeBalancerSettings } from './NodeBalancerSettings'; | ||||||
| import { NodeBalancerSummary } from './NodeBalancerSummary/NodeBalancerSummary'; | ||||||
| import { NodeBalancerSummaryv2 } from './NodeBalancerSummaryv2/NodeBalancerSummaryv2'; | ||||||
|
|
||||||
| export const NodeBalancerDetail = () => { | ||||||
| const { id } = useParams({ | ||||||
|
|
@@ -31,6 +33,8 @@ export const NodeBalancerDetail = () => { | |||||
| reset, | ||||||
| } = useNodebalancerUpdateMutation(Number(id)); | ||||||
|
|
||||||
| const { aclpNbMetricsIntegration } = useFlags(); | ||||||
|
|
||||||
| const { | ||||||
| data: nodebalancer, | ||||||
| error, | ||||||
|
|
@@ -43,7 +47,7 @@ export const NodeBalancerDetail = () => { | |||||
| nodebalancer?.id | ||||||
| ); | ||||||
|
|
||||||
| const { handleTabChange, tabIndex, tabs } = useTabs([ | ||||||
| const { getTabIndex, handleTabChange, tabIndex, tabs } = useTabs([ | ||||||
| { | ||||||
| title: 'Summary', | ||||||
| to: '/nodebalancers/$id/summary', | ||||||
|
|
@@ -52,6 +56,12 @@ export const NodeBalancerDetail = () => { | |||||
| title: 'Configurations', | ||||||
| to: '/nodebalancers/$id/configurations', | ||||||
| }, | ||||||
| { | ||||||
| title: 'Metrics', | ||||||
| to: '/nodebalancers/$id/metrics', | ||||||
| hide: !aclpNbMetricsIntegration, | ||||||
| chip: <NewFeatureChip />, | ||||||
|
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.
Suggested change
Let's use the |
||||||
| }, | ||||||
| { | ||||||
| title: 'Settings', | ||||||
| to: '/nodebalancers/$id/settings', | ||||||
|
|
@@ -75,6 +85,9 @@ export const NodeBalancerDetail = () => { | |||||
| const errorMap = getErrorMap(['label'], updateError); | ||||||
| const labelError = errorMap.label; | ||||||
|
|
||||||
| const metricsTabIndex = getTabIndex('/nodebalancers/$id/metrics'); | ||||||
| const settingsTabIndex = getTabIndex('/nodebalancers/$id/settings'); | ||||||
|
|
||||||
| return ( | ||||||
| <React.Fragment> | ||||||
| <LandingHeader | ||||||
|
|
@@ -101,14 +114,26 @@ export const NodeBalancerDetail = () => { | |||||
| <React.Suspense fallback={<SuspenseLoader />}> | ||||||
| <TabPanels> | ||||||
| <SafeTabPanel index={0}> | ||||||
| <NodeBalancerSummary /> | ||||||
| {!aclpNbMetricsIntegration ? ( | ||||||
| <NodeBalancerSummary /> | ||||||
| ) : ( | ||||||
| <NodeBalancerSummaryv2 /> | ||||||
| )} | ||||||
| </SafeTabPanel> | ||||||
| <SafeTabPanel index={1}> | ||||||
| <NodeBalancerConfigurationsWrapper /> | ||||||
| </SafeTabPanel> | ||||||
| <SafeTabPanel index={2}> | ||||||
| <NodeBalancerSettings /> | ||||||
| </SafeTabPanel> | ||||||
| {metricsTabIndex !== null && ( | ||||||
| <SafeTabPanel index={metricsTabIndex}> | ||||||
| <Notice text="Metrics tab coming soon.." variant="info" /> | ||||||
| </SafeTabPanel> | ||||||
| )} | ||||||
|
|
||||||
| {settingsTabIndex !== null && ( | ||||||
| <SafeTabPanel index={settingsTabIndex}> | ||||||
| <NodeBalancerSettings /> | ||||||
| </SafeTabPanel> | ||||||
| )} | ||||||
| </TabPanels> | ||||||
| </React.Suspense> | ||||||
| </Tabs> | ||||||
|
|
||||||
141 changes: 141 additions & 0 deletions
141
...es/NodeBalancers/NodeBalancerDetail/NodeBalancerSummaryv2/NodeBalancerDetailBody.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| import { | ||
| convertMegabytesTo, | ||
| nodeBalancerConfigFactory, | ||
| nodeBalancerFactory, | ||
| } from '@linode/utilities'; | ||
| import React from 'react'; | ||
|
|
||
| import { firewallFactory } from 'src/factories'; | ||
| import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
|
||
| import { NodeBalancerDetailBody } from './NodeBalancerDetailBody'; | ||
|
|
||
| const queryMocks = vi.hoisted(() => ({ | ||
| useAllNodeBalancerConfigsQuery: vi.fn().mockReturnValue({ data: [] }), | ||
| useNodeBalancersFirewallsQuery: vi | ||
| .fn() | ||
| .mockReturnValue({ data: { data: [] } }), | ||
| useParams: vi.fn().mockReturnValue({ id: 1 }), | ||
| useRegionsQuery: vi.fn().mockReturnValue({ data: [] }), | ||
| })); | ||
|
|
||
| vi.mock('@tanstack/react-router', async () => { | ||
| const actual = await vi.importActual('@tanstack/react-router'); | ||
| return { | ||
| ...actual, | ||
| useParams: queryMocks.useParams, | ||
| }; | ||
| }); | ||
|
|
||
| vi.mock('@linode/queries', async () => { | ||
| const actual = await vi.importActual('@linode/queries'); | ||
| return { | ||
| ...actual, | ||
| useAllNodeBalancerConfigsQuery: queryMocks.useAllNodeBalancerConfigsQuery, | ||
| useNodeBalancersFirewallsQuery: queryMocks.useNodeBalancersFirewallsQuery, | ||
| useRegionsQuery: queryMocks.useRegionsQuery, | ||
| }; | ||
| }); | ||
|
|
||
| describe('NodeBalancerDetailBody', () => { | ||
| const nodebalancer = nodeBalancerFactory.build({ | ||
| hostname: 'example.com', | ||
| id: 1, | ||
| region: 'us-east', | ||
| tags: ['tag-1'], | ||
| type: 'common', | ||
| }); | ||
|
|
||
| beforeEach(() => { | ||
| queryMocks.useAllNodeBalancerConfigsQuery.mockReturnValue({ | ||
| data: [ | ||
| nodeBalancerConfigFactory.build({ id: 101, port: 80 }), | ||
| nodeBalancerConfigFactory.build({ id: 102, port: 443 }), | ||
| ], | ||
| }); | ||
| queryMocks.useNodeBalancersFirewallsQuery.mockReturnValue({ | ||
| data: { | ||
| data: [firewallFactory.build({ id: 44, label: 'mock-firewall-1' })], | ||
| }, | ||
| }); | ||
| queryMocks.useParams.mockReturnValue({ id: 1 }); | ||
| queryMocks.useRegionsQuery.mockReturnValue({ | ||
| data: [{ id: 'us-east', label: 'Newark, NJ' }], | ||
| }); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| vi.resetAllMocks(); | ||
| }); | ||
|
|
||
| it('renders the nodebalancer details, config links, and firewall link', () => { | ||
| const { getByRole, getByText } = renderWithTheme( | ||
| <NodeBalancerDetailBody nodebalancer={nodebalancer} /> | ||
| ); | ||
|
|
||
| expect(getByText('Type')).toBeVisible(); | ||
| expect(getByText('Basic')).toBeVisible(); | ||
| expect(getByText('Region')).toBeVisible(); | ||
| expect(getByText('Newark, NJ')).toBeVisible(); | ||
| expect(getByText('NodeBalancer ID')).toBeVisible(); | ||
| expect(getByText(String(nodebalancer.id))).toBeVisible(); | ||
|
|
||
| expect(getByText('Configuration Ports')).toBeVisible(); | ||
|
|
||
| const port80Link = getByRole('link', { name: 'Port 80' }); | ||
| expect(port80Link).toHaveAttribute( | ||
| 'href', | ||
| `/nodebalancers/${nodebalancer.id}/configurations/101` | ||
| ); | ||
|
|
||
| const port443Link = getByRole('link', { name: 'Port 443' }); | ||
| expect(port443Link).toHaveAttribute( | ||
| 'href', | ||
| `/nodebalancers/${nodebalancer.id}/configurations/102` | ||
| ); | ||
|
|
||
| expect(getByText('Hostname')).toBeVisible(); | ||
| expect(getByText(nodebalancer.hostname)).toBeVisible(); | ||
| expect(getByText('Transferred')).toBeVisible(); | ||
| expect( | ||
| getByText(convertMegabytesTo(nodebalancer.transfer.total)) | ||
| ).toBeVisible(); | ||
|
|
||
| expect(getByText('Firewall')).toBeVisible(); | ||
| const firewallLink = getByRole('link', { | ||
| name: 'Firewall mock-firewall-1', | ||
| }); | ||
| expect(firewallLink).toHaveAttribute('href', '/firewalls/44'); | ||
| }); | ||
|
|
||
| it('renders None when there are no configuration ports and hides the firewall section when there is no firewall', () => { | ||
| queryMocks.useAllNodeBalancerConfigsQuery.mockReturnValue({ | ||
| data: [], | ||
| }); | ||
| queryMocks.useNodeBalancersFirewallsQuery.mockReturnValue({ | ||
| data: { | ||
| data: [], | ||
| }, | ||
| }); | ||
|
|
||
| const { getByText, queryByText } = renderWithTheme( | ||
| <NodeBalancerDetailBody nodebalancer={nodebalancer} /> | ||
| ); | ||
|
|
||
| expect(getByText('Configuration Ports')).toBeVisible(); | ||
| expect(getByText('None')).toBeVisible(); | ||
| expect(queryByText('Firewall')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('falls back to the raw region id when the region lookup is unavailable', () => { | ||
| queryMocks.useRegionsQuery.mockReturnValue({ | ||
| data: [], | ||
| }); | ||
|
|
||
| const { getByText } = renderWithTheme( | ||
| <NodeBalancerDetailBody nodebalancer={nodebalancer} /> | ||
| ); | ||
|
|
||
| expect(getByText(nodebalancer.region)).toBeVisible(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It might be better to rename it to something clearer with proper casing, like
NodeBalancerSummaryV2OR alternatively move the versioning into the folder structure instead of including it in the component name.