diff --git a/.changeset/brown-kings-wait.md b/.changeset/brown-kings-wait.md new file mode 100644 index 0000000000..db3fc0ee86 --- /dev/null +++ b/.changeset/brown-kings-wait.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': patch +--- + +The list of entities takes into account the title when its different from the name to sort the entities. diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx index 935e002375..18080bb7b0 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx @@ -16,6 +16,7 @@ import { ANNOTATION_EDIT_URL, ANNOTATION_VIEW_URL, + Entity, RELATION_OWNED_BY, RELATION_PART_OF, } from '@backstage/catalog-model'; @@ -62,6 +63,16 @@ const YellowStar = withStyles({ }, })(Star); +const refCompare = (a: Entity, b: Entity) => { + const toRef = (entity: Entity) => + entity.metadata.title || + humanizeEntityRef(entity, { + defaultKind: 'Component', + }); + + return toRef(a).localeCompare(toRef(b)); +}; + /** @public */ export const CatalogTable = (props: CatalogTableProps) => { const { columns, actions, tableOptions, subtitle, emptyContent } = props; @@ -177,7 +188,7 @@ export const CatalogTable = (props: CatalogTableProps) => { }, ]; - const rows = entities.map(entity => { + const rows = entities.sort(refCompare).map(entity => { const partOfSystemRelations = getEntityRelations(entity, RELATION_PART_OF, { kind: 'system', });