Fixes #21798 StarredEntities home page component calls getEntitiesByRefs instead of getEntities

Signed-off-by: Jordan Slott <jordan.slott@twosigma.com>
This commit is contained in:
Jordan Slott
2023-12-10 19:13:52 -05:00
parent 65d80d0a8f
commit 54cef2705d
3 changed files with 12 additions and 19 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-home': patch
---
StarredEntities component calls `getEntitiesByRefs` instead of `getEntities` to improve performance since we have the `entityRefs`
@@ -49,7 +49,7 @@ describe('StarredEntitiesContent', () => {
mockedApi.toggleStarred('component:default/mock-starred-entity-3');
const mockCatalogApi = {
getEntities: jest
getEntitiesByRefs: jest
.fn()
.mockImplementation(async () => ({ items: entities })),
};
@@ -87,7 +87,7 @@ describe('StarredEntitiesContent', () => {
const mockedApi = new MockStarredEntitiesApi();
const mockCatalogApi = {
getEntities: jest
getEntitiesByRefs: jest
.fn()
.mockImplementation(async () => ({ items: entities })),
};
@@ -117,7 +117,7 @@ describe('StarredEntitiesContent', () => {
const mockedApi = new MockStarredEntitiesApi();
const mockCatalogApi = {
getEntities: jest
getEntitiesByRefs: jest
.fn()
.mockImplementation(async () => ({ items: entities })),
};
@@ -18,11 +18,7 @@ import {
catalogApiRef,
useStarredEntities,
} from '@backstage/plugin-catalog-react';
import {
Entity,
parseEntityRef,
stringifyEntityRef,
} from '@backstage/catalog-model';
import { Entity, stringifyEntityRef } from '@backstage/catalog-model';
import { useApi } from '@backstage/core-plugin-api';
import { Progress, ResponseErrorPanel } from '@backstage/core-components';
import { List, Typography, Tabs, Tab } from '@material-ui/core';
@@ -55,17 +51,9 @@ export const Content = ({
return [];
}
const filter = [...starredEntities]
.map(ent => parseEntityRef(ent))
.map(ref => ({
kind: ref.kind,
'metadata.namespace': ref.namespace,
'metadata.name': ref.name,
}));
return (
await catalogApi.getEntities({
filter,
await catalogApi.getEntitiesByRefs({
entityRefs: [...starredEntities],
fields: [
'kind',
'metadata.namespace',
@@ -73,7 +61,7 @@ export const Content = ({
'metadata.title',
],
})
).items;
).items.filter((e): e is Entity => !!e);
}, [catalogApi, starredEntities]);
if (starredEntities.size === 0)