Merge pull request #6580 from deepak-bhardwaj-ps/k8s-plugin
Display namespace in deployment summary
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-kubernetes': patch
|
||||
---
|
||||
|
||||
Enhanced deployment accordion to display the namespace of the deployment.
|
||||
@@ -15,20 +15,17 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import * as deployments from '../../__fixtures__/2-deployments.json';
|
||||
import { wrapInTestApp } from '@backstage/test-utils';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { DeploymentDrawer } from './DeploymentDrawer';
|
||||
|
||||
describe('DeploymentDrawer', () => {
|
||||
it('should render deployment drawer', async () => {
|
||||
const { getByText, getAllByText } = render(
|
||||
wrapInTestApp(
|
||||
<DeploymentDrawer
|
||||
deployment={(deployments as any).deployments[0]}
|
||||
expanded
|
||||
/>,
|
||||
),
|
||||
const { getByText, getAllByText } = await renderInTestApp(
|
||||
<DeploymentDrawer
|
||||
deployment={(deployments as any).deployments[0]}
|
||||
expanded
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(getAllByText('dice-roller')).toHaveLength(2);
|
||||
@@ -45,6 +42,22 @@ describe('DeploymentDrawer', () => {
|
||||
expect(getByText('600')).toBeInTheDocument();
|
||||
expect(getByText('Progressing')).toBeInTheDocument();
|
||||
expect(getByText('Available')).toBeInTheDocument();
|
||||
expect(getByText('namespace: default')).toBeInTheDocument();
|
||||
expect(getAllByText('True')).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('should render deployment drawer without namespace', async () => {
|
||||
const deployment = (deployments as any).deployments[0];
|
||||
const { queryByText } = await renderInTestApp(
|
||||
<DeploymentDrawer
|
||||
deployment={{
|
||||
...deployment,
|
||||
metadata: { ...deployment.metadata, namespace: undefined },
|
||||
}}
|
||||
expanded
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(queryByText('namespace: default')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ import React from 'react';
|
||||
import { V1Deployment } from '@kubernetes/client-node';
|
||||
import { KubernetesDrawer } from '../KubernetesDrawer/KubernetesDrawer';
|
||||
import { renderCondition } from '../../utils/pod';
|
||||
import { Typography, Grid } from '@material-ui/core';
|
||||
import { Typography, Grid, Chip } from '@material-ui/core';
|
||||
|
||||
export const DeploymentDrawer = ({
|
||||
deployment,
|
||||
@@ -27,6 +27,7 @@ export const DeploymentDrawer = ({
|
||||
deployment: V1Deployment;
|
||||
expanded?: boolean;
|
||||
}) => {
|
||||
const namespace = deployment.metadata?.namespace;
|
||||
return (
|
||||
<KubernetesDrawer
|
||||
object={deployment}
|
||||
@@ -66,6 +67,11 @@ export const DeploymentDrawer = ({
|
||||
Deployment
|
||||
</Typography>
|
||||
</Grid>
|
||||
{namespace && (
|
||||
<Grid item>
|
||||
<Chip size="small" label={`namespace: ${namespace}`} />
|
||||
</Grid>
|
||||
)}
|
||||
</Grid>
|
||||
</KubernetesDrawer>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user