refactor: move blueprints to react package

Signed-off-by: secustor <sebastian@poxhofer.at>
This commit is contained in:
secustor
2025-09-03 18:21:53 +02:00
parent f4d9086331
commit be6cef5dab
17 changed files with 262 additions and 30 deletions
@@ -0,0 +1,68 @@
/*
* Copyright 2024 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 {
createExtensionBlueprint,
ExtensionBoundary,
} from '@backstage/frontend-plugin-api';
import { devToolsRouteDataRef } from './devToolsRouteDataRef';
import { JSX } from 'react';
/**
* Parameters for creating a DevTools route extension
* @alpha
*/
export interface DevToolsRouteBlueprintParams {
path: string;
title: string;
loader: () => Promise<JSX.Element>;
}
/**
* Extension blueprint for creating DevTools routes
*
* @example
* ```tsx
* const myDevToolsRoute = DevToolsRouteBlueprint.make({
* params: {
* path: 'my-feature',
* title: 'My Feature',
* loader: () => import('./MyContent').then(m => ({ default: m.MyContent }))
* }
* });
* ```
*
* @alpha
*/
export const DevToolsRouteBlueprint = createExtensionBlueprint({
kind: 'devtools-route',
attachTo: { id: 'page:devtools', input: 'routes' },
output: [devToolsRouteDataRef],
factory(params: DevToolsRouteBlueprintParams, { node }) {
const children = ExtensionBoundary.lazy(node, params.loader);
return [
devToolsRouteDataRef({
path: params.path,
title: params.title,
children,
}),
];
},
dataRefs: {
route: devToolsRouteDataRef,
},
});
@@ -0,0 +1,37 @@
/*
* Copyright 2024 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 { createExtensionDataRef } from '@backstage/frontend-plugin-api';
import { JSX } from 'react';
/**
* Represents a DevTools route that can be contributed by extensions
* @alpha
*/
export interface DevToolsRouteData {
path: string;
title: string;
children: JSX.Element;
}
/**
* Extension data reference for DevTools routes
* @alpha
*/
export const devToolsRouteDataRef =
createExtensionDataRef<DevToolsRouteData>().with({
id: 'devtools.route',
});
+29
View File
@@ -0,0 +1,29 @@
/*
* Copyright 2025 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.
*/
/**
* Web library for the devtools plugin.
*
* @packageDocumentation
*/
export {
type DevToolsRouteData,
devToolsRouteDataRef,
} from './devToolsRouteDataRef';
export {
type DevToolsRouteBlueprintParams,
DevToolsRouteBlueprint,
} from './devToolsRouteBlueprint.tsx';