Display title in Cluster accordion

Signed-off-by: Jamie Klassen <jamie.klassen@broadcom.com>
This commit is contained in:
Jamie Klassen
2024-01-22 11:50:12 -05:00
parent 3b3d549a5f
commit 2b305eb7f2
3 changed files with 29 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-kubernetes-react': patch
---
The `Cluster` component now renders the cluster's title, if specified.
@@ -56,4 +56,25 @@ describe('Cluster', () => {
expect(screen.getByText('cluster-1')).toBeInTheDocument();
expect(screen.getByText('10 pods')).toBeInTheDocument();
});
it('renders title', async () => {
await renderInTestApp(
<Cluster
{...({
clusterObjects: {
cluster: {
name: 'cluster-1',
title: 'Cluster Number One',
},
resources: [],
podMetrics: [],
errors: [],
},
podsWithErrors: new Set<string>(),
} as any)}
/>,
);
expect(screen.getByText('Cluster Number One')).toBeInTheDocument();
});
});
@@ -132,7 +132,9 @@ export const Cluster = ({ clusterObjects, podsWithErrors }: ClusterProps) => {
<Accordion TransitionProps={{ unmountOnExit: true }}>
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
<ClusterSummary
clusterName={clusterObjects.cluster.name}
clusterName={
clusterObjects.cluster.title || clusterObjects.cluster.name
}
totalNumberOfPods={groupedResponses.pods.length}
numberOfPodsWithErrors={podsWithErrors.size}
/>