catalog-react: Remove useEntityKinds

Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2022-03-04 14:01:23 +01:00
parent 095cb91294
commit cf1ff5b438
5 changed files with 5 additions and 100 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-react': minor
---
**BREAKING**: Removed `useEntityKinds` hook.
-7
View File
@@ -512,13 +512,6 @@ export function useEntity<TEntity extends Entity = Entity>(): {
refresh?: VoidFunction;
};
// @public @deprecated
export function useEntityKinds(): {
error: Error | undefined;
loading: boolean;
kinds: string[] | undefined;
};
// @public
export function useEntityList<
EntityFilters extends DefaultEntityFilters = DefaultEntityFilters,
-1
View File
@@ -35,7 +35,6 @@ export type {
} from './useEntityListProvider';
export { useEntityTypeFilter } from './useEntityTypeFilter';
export type { EntityTypeReturn } from './useEntityTypeFilter';
export { useEntityKinds } from './useEntityKinds';
export { useOwnUser } from './useOwnUser';
export { useRelatedEntities } from './useRelatedEntities';
export { useStarredEntities } from './useStarredEntities';
@@ -1,53 +0,0 @@
/*
* Copyright 2021 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React, { PropsWithChildren } from 'react';
import { CatalogApi } from '@backstage/catalog-client';
import { catalogApiRef } from '../api';
import { renderHook } from '@testing-library/react-hooks';
import { useEntityKinds } from './useEntityKinds';
import { TestApiProvider } from '@backstage/test-utils';
const mockCatalogApi: Partial<CatalogApi> = {
getEntityFacets: jest.fn().mockResolvedValue({
facets: {
kind: [
{ value: 'Template', count: 2 },
{ value: 'System', count: 1 },
{ value: 'Component', count: 3 },
],
},
}),
};
const wrapper = ({ children }: PropsWithChildren<{}>) => {
return (
<TestApiProvider apis={[[catalogApiRef, mockCatalogApi]]}>
{children}
</TestApiProvider>
);
};
describe('useEntityKinds', () => {
it('gets entity kinds', async () => {
const { result, waitForValueToChange } = renderHook(
() => useEntityKinds(),
{ wrapper },
);
await waitForValueToChange(() => result.current);
expect(result.current.kinds).toEqual(['Component', 'System', 'Template']);
});
});
@@ -1,39 +0,0 @@
/*
* Copyright 2021 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import useAsync from 'react-use/lib/useAsync';
import { useApi } from '@backstage/core-plugin-api';
import { catalogApiRef } from '../api';
/**
* Retrieve a list of unique entity kinds present in the catalog
* @public
* @deprecated and will be removed due to low utility value.
*/
export function useEntityKinds() {
const catalogApi = useApi(catalogApiRef);
const {
error,
loading,
value: kinds,
} = useAsync(async () => {
return await catalogApi
.getEntityFacets({ facets: ['kind'] })
.then(response => response.facets.kind?.map(f => f.value).sort() || []);
});
return { error, loading, kinds };
}