NavLink->Link, NavButton->Button, remove redirects for now

This commit is contained in:
Ivan Shmidt
2020-06-04 00:03:34 +02:00
parent 6a0daf10ca
commit af56473342
16 changed files with 83 additions and 119 deletions
+23 -17
View File
@@ -39,14 +39,19 @@ Each plugin is responsible for registering its components to corresponding route
The app will call the `createPlugin` method on each plugin, passing in a `router` object with a set
of methods on it.
```typescript
import { createPlugin } from '@backstage/core';
```jsx
import { createPlugin, createRouteRef } from '@backstage/core';
import ExampleComponent from './components/ExampleComponent';
export default createPlugin({
id: 'my-plugin',
export const rootRouteRef = createRouteRef({
path: '/new-plugin',
title: 'New plugin',
});
export const plugin = createPlugin({
id: 'new-plugin',
register({ router }) {
router.registerRoute('/my-plugin', ExampleComponent);
router.addRoute(rootRouteRef, ExampleComponent);
},
});
```
@@ -54,17 +59,18 @@ export default createPlugin({
#### `router` API
```typescript
type RouterHooks = {
registerRoute(
path: RoutePath,
Component: ComponentType<any>,
options?: RouteOptions,
): void;
addRoute(
target: RouteRef,
Component: ComponentType<any>,
options?: RouteOptions,
): void;
registerRedirect(
path: RoutePath,
target: RoutePath,
options?: RouteOptions,
): void;
};
/**
* @deprecated See the `addRoute` method
*/
registerRoute(
path: RoutePath,
Component: ComponentType<any>,
options?: RouteOptions,
): void;
```
@@ -47,7 +47,6 @@ import { createPlugin, createRouteRef } from '@backstage/core';
import ExampleComponent from './components/ExampleComponent';
export const rootRouteRef = createRouteRef({
icon: () => null,
path: '/new-plugin',
title: 'New plugin',
});
+1 -13
View File
@@ -10,8 +10,6 @@ addRoute(
options?: RouteOptions,
): void;
addRedirect(from: RouteRef, to: RouteRef, options?: RouteOptions): void;
/**
* @deprecated See the `addRoute` method
*/
@@ -20,26 +18,16 @@ registerRoute(
Component: ComponentType<any>,
options?: RouteOptions,
): void;
/**
* @deprecated See the `addRedirect` method
*/
registerRedirect(
path: RoutePath,
target: RoutePath,
options?: RouteOptions,
): void;
```
## RouteRef
Both `addRoute` and `addRedirect` methods are using mutable RouteRefs, which can be created as following:
`addRoute` method is using mutable RouteRefs, which can be created as following:
```ts
import { createRouteRef } from '@backstage/core';
const myPluginRouteRef = createRouteRef({
icon: () => null, // You can set an icon for your route
path: '/my-plugin',
title: 'My Plugin',
});