From e95b379d5f565bf38ad4ca8fa02bc7abb38f3c3c Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 11 Sep 2021 14:14:50 +0200 Subject: [PATCH] catalog: remove EntityLoaderProvider and deprecate Router Signed-off-by: Patrik Oldsberg --- .changeset/sweet-turtles-remain.md | 5 ++++ plugins/catalog/api-report.md | 2 +- .../CatalogEntityPage/CatalogEntityPage.tsx | 17 ++++++----- .../EntityLoaderProvider.tsx | 30 ------------------- .../components/EntityLoaderProvider/index.ts | 16 ---------- plugins/catalog/src/components/Router.tsx | 16 +++++++--- 6 files changed, 27 insertions(+), 59 deletions(-) create mode 100644 .changeset/sweet-turtles-remain.md delete mode 100644 plugins/catalog/src/components/EntityLoaderProvider/EntityLoaderProvider.tsx delete mode 100644 plugins/catalog/src/components/EntityLoaderProvider/index.ts diff --git a/.changeset/sweet-turtles-remain.md b/.changeset/sweet-turtles-remain.md new file mode 100644 index 0000000000..30cd1cd700 --- /dev/null +++ b/.changeset/sweet-turtles-remain.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': patch +--- + +Deprecated `Router` in favor of using the plugin extensions. diff --git a/plugins/catalog/api-report.md b/plugins/catalog/api-report.md index 689c617158..6034031fae 100644 --- a/plugins/catalog/api-report.md +++ b/plugins/catalog/api-report.md @@ -401,7 +401,7 @@ export const isOrphan: (entity: Entity) => boolean; // Warning: (ae-missing-release-tag) "Router" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // -// @public (undocumented) +// @public @deprecated (undocumented) export const Router: ({ EntityPage, }: { diff --git a/plugins/catalog/src/components/CatalogEntityPage/CatalogEntityPage.tsx b/plugins/catalog/src/components/CatalogEntityPage/CatalogEntityPage.tsx index 37c2ec7139..94b9f5eee4 100644 --- a/plugins/catalog/src/components/CatalogEntityPage/CatalogEntityPage.tsx +++ b/plugins/catalog/src/components/CatalogEntityPage/CatalogEntityPage.tsx @@ -16,12 +16,13 @@ import React from 'react'; import { Outlet } from 'react-router'; -import { EntityLoaderProvider } from '../EntityLoaderProvider'; +import { + useEntityFromUrl, + AsyncEntityProvider, +} from '@backstage/plugin-catalog-react'; -export const CatalogEntityPage = () => { - return ( - - - - ); -}; +export const CatalogEntityPage = () => ( + + + +); diff --git a/plugins/catalog/src/components/EntityLoaderProvider/EntityLoaderProvider.tsx b/plugins/catalog/src/components/EntityLoaderProvider/EntityLoaderProvider.tsx deleted file mode 100644 index 8d2feae7da..0000000000 --- a/plugins/catalog/src/components/EntityLoaderProvider/EntityLoaderProvider.tsx +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2020 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 { - EntityContext, - useEntityFromUrl, -} from '@backstage/plugin-catalog-react'; -import React, { ReactNode } from 'react'; - -export const EntityLoaderProvider = ({ children }: { children: ReactNode }) => { - const { entity, loading, error, refresh } = useEntityFromUrl(); - - return ( - - {children} - - ); -}; diff --git a/plugins/catalog/src/components/EntityLoaderProvider/index.ts b/plugins/catalog/src/components/EntityLoaderProvider/index.ts deleted file mode 100644 index 8422e6dc4b..0000000000 --- a/plugins/catalog/src/components/EntityLoaderProvider/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2020 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. - */ -export { EntityLoaderProvider } from './EntityLoaderProvider'; diff --git a/plugins/catalog/src/components/Router.tsx b/plugins/catalog/src/components/Router.tsx index d0e0d5dcce..9116c0b551 100644 --- a/plugins/catalog/src/components/Router.tsx +++ b/plugins/catalog/src/components/Router.tsx @@ -15,15 +15,16 @@ */ import { ENTITY_DEFAULT_NAMESPACE } from '@backstage/catalog-model'; import { + AsyncEntityProvider, entityRoute, rootRoute, useEntity, + useEntityFromUrl, } from '@backstage/plugin-catalog-react'; import { Link, Typography } from '@material-ui/core'; -import React, { ComponentType } from 'react'; +import React, { ComponentType, ReactNode } from 'react'; import { Navigate, Route, Routes, useParams } from 'react-router'; import { CatalogPage } from './CatalogPage'; -import { EntityLoaderProvider } from './EntityLoaderProvider'; import { EntityNotFound } from './EntityNotFound'; import { EntityPageLayout } from './EntityPageLayout'; import { Content } from '@backstage/core-components'; @@ -73,6 +74,13 @@ const OldEntityRouteRedirect = () => { ); }; +export const EntityLoader = (props: { children: ReactNode }) => ( + +); + +/** + * @deprecated Use plugin extensions instead + * */ export const Router = ({ EntityPage = DefaultEntityPage, }: { @@ -83,9 +91,9 @@ export const Router = ({ + - + } />