Skip to content

Commit

Permalink
catalog: remove EntityLoaderProvider and deprecate Router
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
  • Loading branch information
Rugvip committed Sep 11, 2021
1 parent ea81a1f commit e95b379
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 59 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-turtles-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog': patch
---

Deprecated `Router` in favor of using the plugin extensions.
2 changes: 1 addition & 1 deletion plugins/catalog/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<EntityLoaderProvider>
<Outlet />
</EntityLoaderProvider>
);
};
export const CatalogEntityPage = () => (
<AsyncEntityProvider {...useEntityFromUrl()}>
<Outlet />
</AsyncEntityProvider>
);

This file was deleted.

16 changes: 0 additions & 16 deletions plugins/catalog/src/components/EntityLoaderProvider/index.ts

This file was deleted.

16 changes: 12 additions & 4 deletions plugins/catalog/src/components/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -73,6 +74,13 @@ const OldEntityRouteRedirect = () => {
);
};

export const EntityLoader = (props: { children: ReactNode }) => (
<AsyncEntityProvider {...useEntityFromUrl()} {...props} />
);

/**
* @deprecated Use plugin extensions instead
* */
export const Router = ({
EntityPage = DefaultEntityPage,
}: {
Expand All @@ -83,9 +91,9 @@ export const Router = ({
<Route
path={`${entityRoute.path}`}
element={
<EntityLoaderProvider>
<EntityLoader>
<EntityPageSwitch EntityPage={EntityPage} />
</EntityLoaderProvider>
</EntityLoader>
}
/>
<Route
Expand Down

0 comments on commit e95b379

Please sign in to comment.