From 809eefb91c1af070d12dc4055c0bc18ede533d22 Mon Sep 17 00:00:00 2001 From: Johan Persson Date: Mon, 2 Mar 2026 11:27:02 +0100 Subject: [PATCH] refactor(catalog): migrate EntityLabelsCard table to BUI Table Signed-off-by: Johan Persson --- .../EntityLabelsCard/EntityLabelsCard.tsx | 61 ++++++++----------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/plugins/catalog/src/components/EntityLabelsCard/EntityLabelsCard.tsx b/plugins/catalog/src/components/EntityLabelsCard/EntityLabelsCard.tsx index 070d1266e2..8c096932f8 100644 --- a/plugins/catalog/src/components/EntityLabelsCard/EntityLabelsCard.tsx +++ b/plugins/catalog/src/components/EntityLabelsCard/EntityLabelsCard.tsx @@ -15,10 +15,13 @@ */ import { useEntity, EntityInfoCard } from '@backstage/plugin-catalog-react'; -import { Table, TableColumn } from '@backstage/core-components'; import { EntityLabelsEmptyState } from './EntityLabelsEmptyState'; -import Typography from '@material-ui/core/Typography'; -import { makeStyles } from '@material-ui/core/styles'; +import { + Table, + CellText, + type ColumnConfig, + type TableItem, +} from '@backstage/ui'; import { catalogTranslationRef } from '../../alpha/translation'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; @@ -31,33 +34,31 @@ export interface EntityLabelsCardProps { title?: string; } -const useStyles = makeStyles(_ => ({ - key: { - fontWeight: 'bold', +interface LabelItem extends TableItem { + id: string; + key: string; + value: string; +} + +const columnConfig: ColumnConfig[] = [ + { + id: 'key', + label: 'Label', + isRowHeader: true, + cell: item => , }, -})); + { + id: 'value', + label: 'Value', + cell: item => , + }, +]; export const EntityLabelsCard = (props: EntityLabelsCardProps) => { const { variant: _variant, title } = props; const { entity } = useEntity(); - const classes = useStyles(); const { t } = useTranslationRef(catalogTranslationRef); - const columns: TableColumn<{ key: string; value: string }>[] = [ - { - render: row => { - return ( - - {row.key} - - ); - }, - }, - { - field: 'value', - }, - ]; - const labels = entity?.metadata?.labels; return ( @@ -66,21 +67,13 @@ export const EntityLabelsCard = (props: EntityLabelsCardProps) => { ) : ( ({ + id: labelKey, key: labelKey, value: labels[labelKey], }))} - options={{ - search: false, - showTitle: true, - loadingType: 'linear', - header: false, - padding: 'dense', - pageSize: 5, - toolbar: false, - paging: Object.keys(labels).length > 5, - }} + pagination={{ type: 'none' }} /> )}