core-plugin-api: add forwards compatibility for route refs
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -38,7 +38,6 @@ In order to migrate the actual definition of the plugin you need to recreate the
|
||||
|
||||
```ts title="my-plugin/src/alpha.tsx"
|
||||
import { createFrontendPlugin } from '@backstage/frontend-plugin-api';
|
||||
import { convertLegacyRouteRefs } from '@backstage/core-compat-api';
|
||||
|
||||
export default createFrontendPlugin({
|
||||
// The plugin ID is now provided as `pluginId` instead of `id`
|
||||
@@ -47,15 +46,12 @@ In order to migrate the actual definition of the plugin you need to recreate the
|
||||
// bind all the extensions to the plugin
|
||||
/* highlight-next-line */
|
||||
extensions: [/* APIs will go here, but don't worry about those yet */],
|
||||
// convert old route refs to the new system
|
||||
/* highlight-next-line */
|
||||
routes: convertLegacyRouteRefs({
|
||||
routes: {
|
||||
...
|
||||
}),
|
||||
/* highlight-next-line */
|
||||
externalRoutes: convertLegacyRouteRefs({
|
||||
},
|
||||
externalRoutes: {
|
||||
...
|
||||
}),
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
@@ -110,18 +106,15 @@ it can be migrated as the following, keeping in mind that you may need to switch
|
||||
|
||||
```tsx
|
||||
import { PageBlueprint } from '@backstage/frontend-plugin-api';
|
||||
import {
|
||||
compatWrapper,
|
||||
convertLegacyRouteRef,
|
||||
} from '@backstage/core-compat-api';
|
||||
import { compatWrapper } from '@backstage/core-compat-api';
|
||||
|
||||
const fooPage = PageBlueprint.make({
|
||||
params: {
|
||||
// This is the path that was previously defined in the app code.
|
||||
// It's labelled as the default one because it can be changed via configuration.
|
||||
path: '/foo',
|
||||
// You can reuse the existing routeRef by wrapping it with convertLegacyRouteRef.
|
||||
routeRef: convertLegacyRouteRef(rootRouteRef),
|
||||
// You can reuse the existing routeRef.
|
||||
routeRef: rootRouteRef,
|
||||
// these inputs usually match the props required by the component.
|
||||
loader: () =>
|
||||
import('./components/').then(m =>
|
||||
|
||||
Reference in New Issue
Block a user