frontend-plugin-api: updates to use new routing API
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -14,9 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { IconComponent, RouteRef } from '@backstage/core-plugin-api';
|
||||
import { IconComponent } from '@backstage/core-plugin-api';
|
||||
import { createSchemaFromZod } from '../schema/createSchemaFromZod';
|
||||
import { coreExtensionData, createExtension } from '../wiring';
|
||||
import { RouteRef } from '../routing';
|
||||
|
||||
/**
|
||||
* Helper for creating extensions for a nav item.
|
||||
@@ -24,7 +25,7 @@ import { coreExtensionData, createExtension } from '../wiring';
|
||||
*/
|
||||
export function createNavItemExtension(options: {
|
||||
id: string;
|
||||
routeRef: RouteRef;
|
||||
routeRef: RouteRef<undefined>;
|
||||
title: string;
|
||||
icon: IconComponent;
|
||||
}) {
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { RouteRef } from '@backstage/core-plugin-api';
|
||||
import React from 'react';
|
||||
import { ExtensionBoundary } from '../components';
|
||||
import { createSchemaFromZod, PortableSchema } from '../schema';
|
||||
@@ -26,6 +25,7 @@ import {
|
||||
} from '../wiring';
|
||||
import { AnyExtensionInputMap } from '../wiring/createExtension';
|
||||
import { Expand } from '../types';
|
||||
import { RouteRef } from '../routing';
|
||||
|
||||
/**
|
||||
* Helper for creating extensions for a routable React page component.
|
||||
|
||||
@@ -20,15 +20,3 @@
|
||||
* @public
|
||||
*/
|
||||
export type AnyRouteParams = { [param in string]: string } | undefined;
|
||||
|
||||
/**
|
||||
* A duplicate of the react-router RouteObject, but with routeRef added
|
||||
* @internal
|
||||
*/
|
||||
export interface BackstageRouteObject {
|
||||
caseSensitive: boolean;
|
||||
children?: BackstageRouteObject[];
|
||||
element: React.ReactNode;
|
||||
path: string;
|
||||
routeRefs: Set<RouteRef>;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('v1 consumer', () => {
|
||||
const resolve = jest.fn(() => () => '/hello');
|
||||
context.set({ 1: { resolve } });
|
||||
|
||||
const routeRef = createRouteRef({ id: 'ref1' });
|
||||
const routeRef = createRouteRef();
|
||||
|
||||
const renderedHook = renderHook(() => useRouteRef(routeRef), {
|
||||
wrapper: ({ children }: React.PropsWithChildren<{}>) => (
|
||||
@@ -55,7 +55,7 @@ describe('v1 consumer', () => {
|
||||
const resolve = jest.fn(() => () => '/hello');
|
||||
context.set({ 1: { resolve } });
|
||||
|
||||
const routeRef = createRouteRef({ id: 'ref1' });
|
||||
const routeRef = createRouteRef();
|
||||
const history = createBrowserHistory();
|
||||
history.push('/my-page');
|
||||
|
||||
@@ -81,7 +81,7 @@ describe('v1 consumer', () => {
|
||||
const resolve = jest.fn(() => () => '/hello');
|
||||
context.set({ 1: { resolve } });
|
||||
|
||||
const routeRef = createRouteRef({ id: 'ref1' });
|
||||
const routeRef = createRouteRef();
|
||||
const history = createBrowserHistory();
|
||||
history.push('/my-page');
|
||||
|
||||
@@ -107,7 +107,7 @@ describe('v1 consumer', () => {
|
||||
const resolve = jest.fn(() => () => '/hello');
|
||||
context.set({ 1: { resolve } });
|
||||
|
||||
const routeRef = createRouteRef({ id: 'ref1' });
|
||||
const routeRef = createRouteRef();
|
||||
const history = createBrowserHistory();
|
||||
history.push('/my-page');
|
||||
|
||||
@@ -133,7 +133,7 @@ describe('v1 consumer', () => {
|
||||
const resolve = jest.fn(() => () => '/hello');
|
||||
context.set({ 1: { resolve } });
|
||||
|
||||
const routeRef = createRouteRef({ id: 'ref1' });
|
||||
const routeRef = createRouteRef();
|
||||
const history = createBrowserHistory();
|
||||
history.push('/my-page');
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import { createRouteRef } from './RouteRef';
|
||||
describe('useRouteRefParams', () => {
|
||||
it('should provide types params', () => {
|
||||
const routeRef = createRouteRef({
|
||||
id: 'ref1',
|
||||
params: ['a', 'b'],
|
||||
});
|
||||
|
||||
|
||||
@@ -19,15 +19,15 @@ import {
|
||||
AnyApiFactory,
|
||||
AppTheme,
|
||||
IconComponent,
|
||||
RouteRef,
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { createExtensionDataRef } from './createExtensionDataRef';
|
||||
import { RouteRef } from '../routing';
|
||||
|
||||
/** @public */
|
||||
export type NavTarget = {
|
||||
title: string;
|
||||
icon: IconComponent;
|
||||
routeRef: RouteRef<{}>;
|
||||
routeRef: RouteRef<undefined>;
|
||||
};
|
||||
|
||||
/** @public */
|
||||
|
||||
@@ -14,8 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AnyExternalRoutes, AnyRoutes } from '@backstage/core-plugin-api';
|
||||
import { Extension } from './createExtension';
|
||||
import { ExternalRouteRef, RouteRef } from '../routing';
|
||||
|
||||
/** @internal */
|
||||
export type AnyRoutes = { [name in string]: RouteRef };
|
||||
|
||||
/** @internal */
|
||||
export type AnyExternalRoutes = { [name in string]: ExternalRouteRef };
|
||||
|
||||
/** @public */
|
||||
export interface PluginOptions<
|
||||
@@ -42,8 +48,8 @@ export interface BackstagePlugin<
|
||||
|
||||
/** @public */
|
||||
export function createPlugin<
|
||||
Routes extends AnyRoutes = AnyRoutes,
|
||||
ExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes,
|
||||
Routes extends AnyRoutes,
|
||||
ExternalRoutes extends AnyExternalRoutes,
|
||||
>(
|
||||
options: PluginOptions<Routes, ExternalRoutes>,
|
||||
): BackstagePlugin<Routes, ExternalRoutes> {
|
||||
|
||||
Reference in New Issue
Block a user