Fix closing of k8s pod drawer when data reloads (#21415)

* Add ID property to the table displaying kubernetes pods to avoid closing the info sidebar when the data reloads and needs to rerender.

Signed-off-by: Simon Stamm <simon.stamm@tui.com>

* Correct formatting

Signed-off-by: Simon Stamm <simon.stamm@tui.com>

* Change sideboard to drawer

Co-authored-by: Jamie Klassen <jklassen@vmware.com>
Signed-off-by: Simon Stamm <simon@stammtec.de>

---------

Signed-off-by: Simon Stamm <simon.stamm@tui.com>
Signed-off-by: Simon Stamm <simon@stammtec.de>
Co-authored-by: Jamie Klassen <jklassen@vmware.com>
This commit is contained in:
Simon Stamm
2023-11-20 19:11:46 +01:00
committed by GitHub
parent 32d3829060
commit b5ae2e5a62
2 changed files with 18 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-kubernetes-react': patch
---
Add ID property to the table displaying kubernetes pods to avoid closing the info sidebar when the data reloads and needs to rerender.
+13 -1
View File
@@ -125,6 +125,11 @@ const Memory = ({ clusterName, pod }: { clusterName: string; pod: Pod }) => {
export const PodsTable = ({ pods, extraColumns = [] }: PodsTablesProps) => {
const cluster = useContext(ClusterContext);
const defaultColumns: TableColumn<Pod>[] = [
{
title: 'ID',
field: 'metadata.uid',
hidden: true,
},
{
title: 'name',
highlight: true,
@@ -176,7 +181,14 @@ export const PodsTable = ({ pods, extraColumns = [] }: PodsTablesProps) => {
<div style={tableStyle}>
<Table
options={{ paging: true, search: false, emptyRowsWhenPaging: false }}
data={pods as Pod[]}
// It was observed that in some instances the pod drawer closes when new data (like CPU usage) is available and the table reloads.
// Mapping the metadata UID to the tables ID fixes this problem.
data={
(pods as Pod[]).map((pod: Pod) => ({
...pod,
id: pod?.metadata?.uid,
})) as any as Pod[]
}
columns={columns}
/>
</div>