catalog-client: change entities interface, add fields support (#3296)

This commit is contained in:
Fredrik Adelöw
2020-11-18 19:58:36 +01:00
committed by GitHub
parent 16bb5a0c8e
commit 717e43de14
19 changed files with 298 additions and 235 deletions
@@ -26,24 +26,26 @@ import { ApiExplorerPage } from './ApiExplorerPage';
describe('ApiCatalogPage', () => {
const catalogApi: Partial<CatalogApi> = {
getEntities: () =>
Promise.resolve([
{
apiVersion: 'backstage.io/v1alpha1',
kind: 'API',
metadata: {
name: 'Entity1',
Promise.resolve({
items: [
{
apiVersion: 'backstage.io/v1alpha1',
kind: 'API',
metadata: {
name: 'Entity1',
},
spec: { type: 'openapi' },
},
spec: { type: 'openapi' },
},
{
apiVersion: 'backstage.io/v1alpha1',
kind: 'API',
metadata: {
name: 'Entity2',
{
apiVersion: 'backstage.io/v1alpha1',
kind: 'API',
metadata: {
name: 'Entity2',
},
spec: { type: 'openapi' },
},
spec: { type: 'openapi' },
},
] as Entity[]),
] as Entity[],
}),
getLocationByEntity: () =>
Promise.resolve({ id: 'id', type: 'github', target: 'url' }),
};
@@ -25,8 +25,8 @@ import { ApiExplorerLayout } from './ApiExplorerLayout';
export const ApiExplorerPage = () => {
const catalogApi = useApi(catalogApiRef);
const { loading, error, value: matchingEntities } = useAsync(() => {
return catalogApi.getEntities({ kind: 'API' });
const { loading, error, value: catalogResponse } = useAsync(() => {
return catalogApi.getEntities({ filter: { kind: 'API' } });
}, [catalogApi]);
return (
@@ -44,7 +44,7 @@ export const ApiExplorerPage = () => {
<SupportButton>All your APIs</SupportButton>
</ContentHeader>
<ApiExplorerTable
entities={matchingEntities!}
entities={catalogResponse?.items ?? []}
loading={loading}
error={error}
/>