-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upcoming: [M3-8839] - Designate LKE-E clusters with 'Enterprise' chip (…
…#11442) * Create component for rendering cluster chips * Add test coverage for new component * Replace current chip with ClusterChips component * Fix spacing in column specs due to long LKE-E version * Remove Kube dashboard button for LKE-E clusters * Fix the fix for specs spacing * Add changeset * Fix a conditional before I forget * Address feedback - clean up flag mocks in test * Update packages/manager/src/features/Kubernetes/ClusterList/ClusterChips.test.tsx Co-authored-by: Hana Xu <115299789+hana-akamai@users.noreply.github.com> * Update packages/manager/src/features/Kubernetes/KubernetesClusterDetail/KubeClusterSpecs.tsx Co-authored-by: Hana Xu <115299789+hana-akamai@users.noreply.github.com> --------- Co-authored-by: Hana Xu <115299789+hana-akamai@users.noreply.github.com>
- Loading branch information
1 parent
3a93d2a
commit de24b40
Showing
6 changed files
with
215 additions
and
34 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-11442-upcoming-features-1734651568762.md
This file contains 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,5 @@ | ||
--- | ||
"@linode/manager": Upcoming Features | ||
--- | ||
|
||
Designate LKE-E clusters with 'Enterprise' chip ([#11442](https://github.com/linode/manager/pull/11442)) |
119 changes: 119 additions & 0 deletions
119
packages/manager/src/features/Kubernetes/ClusterList/ClusterChips.test.tsx
This file contains 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,119 @@ | ||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import { kubernetesClusterFactory } from 'src/factories'; | ||
import { wrapWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { ClusterChips } from './ClusterChips'; | ||
|
||
const mockCluster = kubernetesClusterFactory.build({ | ||
control_plane: { high_availability: false }, | ||
}); | ||
const mockHACluster = kubernetesClusterFactory.build({ | ||
control_plane: { high_availability: true }, | ||
}); | ||
const mockEnterpriseCluster = kubernetesClusterFactory.build({ | ||
tier: 'enterprise', | ||
}); | ||
const mockStandardCluster = kubernetesClusterFactory.build({ | ||
tier: 'standard', | ||
}); | ||
|
||
const queryMocks = vi.hoisted(() => ({ | ||
useAccount: vi.fn().mockReturnValue({}), | ||
})); | ||
|
||
vi.mock('src/queries/account/account', () => { | ||
const actual = vi.importActual('src/queries/account/account'); | ||
return { | ||
...actual, | ||
useAccount: queryMocks.useAccount, | ||
}; | ||
}); | ||
|
||
describe('Kubernetes cluster action menu', () => { | ||
it('renders an HA chip if the cluster is high availability', () => { | ||
const { getByText } = render( | ||
wrapWithTheme(<ClusterChips cluster={mockHACluster} />) | ||
); | ||
|
||
expect(getByText('HA', { exact: false })); | ||
}); | ||
|
||
it('does not render an HA chip if the cluster is not high availability', () => { | ||
const { queryByText } = render( | ||
wrapWithTheme(<ClusterChips cluster={mockCluster} />) | ||
); | ||
|
||
expect(queryByText('HA', { exact: false })).toBe(null); | ||
}); | ||
|
||
it('renders both enterprise and HA chips for an enterprise cluster if the feature is enabled', () => { | ||
queryMocks.useAccount.mockReturnValue({ | ||
data: { | ||
capabilities: ['Kubernetes Enterprise'], | ||
}, | ||
}); | ||
|
||
const { getByText } = render( | ||
wrapWithTheme(<ClusterChips cluster={mockEnterpriseCluster} />, { | ||
flags: { | ||
lkeEnterprise: { | ||
enabled: true, | ||
ga: false, | ||
la: true, | ||
}, | ||
}, | ||
}) | ||
); | ||
|
||
expect(getByText('HA', { exact: false })).toBeVisible(); | ||
expect(getByText('ENTERPRISE')).toBeVisible(); | ||
}); | ||
|
||
it('does not render an enterprise chip for an enterprise cluster if the feature is disabled', () => { | ||
queryMocks.useAccount.mockReturnValue({ | ||
data: { | ||
capabilities: ['Kubernetes Enterprise'], | ||
}, | ||
}); | ||
|
||
const { getByText, queryByText } = render( | ||
wrapWithTheme(<ClusterChips cluster={mockEnterpriseCluster} />, { | ||
flags: { | ||
lkeEnterprise: { | ||
enabled: false, | ||
ga: false, | ||
la: true, | ||
}, | ||
}, | ||
}) | ||
); | ||
|
||
expect(getByText('HA', { exact: false })).toBeVisible(); | ||
expect(queryByText('ENTERPRISE')).toBe(null); | ||
}); | ||
|
||
it('does not render an enterprise chip for a standard cluster', () => { | ||
queryMocks.useAccount.mockReturnValue({ | ||
data: { | ||
capabilities: ['Kubernetes Enterprise'], | ||
}, | ||
}); | ||
|
||
const { queryByText } = render( | ||
wrapWithTheme(<ClusterChips cluster={mockStandardCluster} />, { | ||
flags: { | ||
lkeEnterprise: { | ||
enabled: true, | ||
ga: false, | ||
la: true, | ||
}, | ||
}, | ||
}) | ||
); | ||
|
||
expect(queryByText('HA')).toBe(null); | ||
expect(queryByText('ENTERPRISE')).toBe(null); | ||
}); | ||
}); |
45 changes: 45 additions & 0 deletions
45
packages/manager/src/features/Kubernetes/ClusterList/ClusterChips.tsx
This file contains 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,45 @@ | ||
import { Chip, Stack } from '@linode/ui'; | ||
import React from 'react'; | ||
import { useHistory } from 'react-router-dom'; | ||
|
||
import { useIsLkeEnterpriseEnabled } from '../kubeUtils'; | ||
|
||
import type { KubernetesCluster } from '@linode/api-v4'; | ||
import type { SxProps, Theme } from '@mui/material'; | ||
|
||
interface Props { | ||
cluster: KubernetesCluster; | ||
sx?: SxProps<Theme>; | ||
} | ||
|
||
export const ClusterChips = (props: Props) => { | ||
const { cluster, sx } = props; | ||
const { isLkeEnterpriseLAFeatureEnabled } = useIsLkeEnterpriseEnabled(); | ||
|
||
const { location } = useHistory(); | ||
|
||
return ( | ||
<Stack columnGap={0.5} flexDirection="row" sx={sx}> | ||
{isLkeEnterpriseLAFeatureEnabled && cluster?.tier === 'enterprise' && ( | ||
<Chip | ||
data-testid="lke-e-chip" | ||
label="ENTERPRISE" | ||
size="small" | ||
sx={(theme) => ({ borderColor: theme.color.blue })} | ||
variant="outlined" | ||
/> | ||
)} | ||
{cluster.control_plane.high_availability && ( | ||
<Chip | ||
label={ | ||
location.pathname === '/kubernetes/clusters' ? 'HA' : 'HA CLUSTER' | ||
} | ||
data-testid="ha-chip" | ||
size="small" | ||
sx={(theme) => ({ borderColor: theme.color.green })} | ||
variant="outlined" | ||
/> | ||
)} | ||
</Stack> | ||
); | ||
}; |
This file contains 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 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 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