refactor(catalog): extract apis extensions file
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2023 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 {
|
||||
createApiFactory,
|
||||
discoveryApiRef,
|
||||
fetchApiRef,
|
||||
storageApiRef,
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { CatalogClient } from '@backstage/catalog-client';
|
||||
import { createApiExtension } from '@backstage/frontend-plugin-api';
|
||||
import {
|
||||
catalogApiRef,
|
||||
starredEntitiesApiRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { DefaultStarredEntitiesApi } from '../apis';
|
||||
|
||||
export const CatalogApi = createApiExtension({
|
||||
factory: createApiFactory({
|
||||
api: catalogApiRef,
|
||||
deps: {
|
||||
discoveryApi: discoveryApiRef,
|
||||
fetchApi: fetchApiRef,
|
||||
},
|
||||
factory: ({ discoveryApi, fetchApi }) =>
|
||||
new CatalogClient({ discoveryApi, fetchApi }),
|
||||
}),
|
||||
});
|
||||
|
||||
export const StarredEntitiesApi = createApiExtension({
|
||||
factory: createApiFactory({
|
||||
api: starredEntitiesApiRef,
|
||||
deps: { storageApi: storageApiRef },
|
||||
factory: ({ storageApi }) => new DefaultStarredEntitiesApi({ storageApi }),
|
||||
}),
|
||||
});
|
||||
|
||||
export default [CatalogApi, StarredEntitiesApi];
|
||||
@@ -18,15 +18,8 @@ import React from 'react';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import HomeIcon from '@material-ui/icons/Home';
|
||||
|
||||
import {
|
||||
createApiFactory,
|
||||
discoveryApiRef,
|
||||
fetchApiRef,
|
||||
storageApiRef,
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { convertLegacyRouteRef } from '@backstage/core-plugin-api/alpha';
|
||||
import {
|
||||
createApiExtension,
|
||||
createPageExtension,
|
||||
createPlugin,
|
||||
createNavItemExtension,
|
||||
@@ -34,12 +27,9 @@ import {
|
||||
createExtensionInput,
|
||||
} from '@backstage/frontend-plugin-api';
|
||||
|
||||
import { CatalogClient } from '@backstage/catalog-client';
|
||||
import {
|
||||
AsyncEntityProvider,
|
||||
catalogApiRef,
|
||||
entityRouteRef,
|
||||
starredEntitiesApiRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import {
|
||||
createEntityContentExtension,
|
||||
@@ -48,7 +38,6 @@ import {
|
||||
} from '@backstage/plugin-catalog-react/alpha';
|
||||
import { createSearchResultListItemExtension } from '@backstage/plugin-search-react/alpha';
|
||||
|
||||
import { DefaultStarredEntitiesApi } from '../apis';
|
||||
import {
|
||||
createComponentRouteRef,
|
||||
createFromTemplateRouteRef,
|
||||
@@ -57,30 +46,9 @@ import {
|
||||
} from '../routes';
|
||||
import { useEntityFromUrl } from '../components/CatalogEntityPage/useEntityFromUrl';
|
||||
|
||||
import apis from './apis';
|
||||
import filters from './filters';
|
||||
|
||||
/** @alpha */
|
||||
export const CatalogApi = createApiExtension({
|
||||
factory: createApiFactory({
|
||||
api: catalogApiRef,
|
||||
deps: {
|
||||
discoveryApi: discoveryApiRef,
|
||||
fetchApi: fetchApiRef,
|
||||
},
|
||||
factory: ({ discoveryApi, fetchApi }) =>
|
||||
new CatalogClient({ discoveryApi, fetchApi }),
|
||||
}),
|
||||
});
|
||||
|
||||
/** @alpha */
|
||||
export const StarredEntitiesApi = createApiExtension({
|
||||
factory: createApiFactory({
|
||||
api: starredEntitiesApiRef,
|
||||
deps: { storageApi: storageApiRef },
|
||||
factory: ({ storageApi }) => new DefaultStarredEntitiesApi({ storageApi }),
|
||||
}),
|
||||
});
|
||||
|
||||
/** @alpha */
|
||||
export const CatalogSearchResultListItemExtension =
|
||||
createSearchResultListItemExtension({
|
||||
@@ -195,9 +163,8 @@ export default createPlugin({
|
||||
createFromTemplate: convertLegacyRouteRef(createFromTemplateRouteRef),
|
||||
},
|
||||
extensions: [
|
||||
...apis,
|
||||
...filters,
|
||||
CatalogApi,
|
||||
StarredEntitiesApi,
|
||||
CatalogSearchResultListItemExtension,
|
||||
CatalogIndexPage,
|
||||
CatalogEntityPage,
|
||||
|
||||
Reference in New Issue
Block a user