frontend-plugin-api: remove deprecated variant of createFrontendPlugin
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/frontend-plugin-api': minor
|
||||
---
|
||||
|
||||
**BREAKING**: Removed the deprecated `createFrontendPlugin` variant where the plugin ID is passed via an `id` option. To update existing code, switch to using the `pluginId` option instead.
|
||||
@@ -817,29 +817,6 @@ export function createFrontendPlugin<
|
||||
MakeSortedExtensionsMap<TExtensions[number], TId>
|
||||
>;
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
export function createFrontendPlugin<
|
||||
TId extends string,
|
||||
TRoutes extends {
|
||||
[name in string]: RouteRef | SubRouteRef;
|
||||
} = {},
|
||||
TExternalRoutes extends {
|
||||
[name in string]: ExternalRouteRef;
|
||||
} = {},
|
||||
TExtensions extends readonly ExtensionDefinition[] = [],
|
||||
>(
|
||||
options: Omit<
|
||||
PluginOptions<TId, TRoutes, TExternalRoutes, TExtensions>,
|
||||
'pluginId'
|
||||
> & {
|
||||
id: string;
|
||||
},
|
||||
): FrontendPlugin<
|
||||
TRoutes,
|
||||
TExternalRoutes,
|
||||
MakeSortedExtensionsMap<TExtensions[number], TId>
|
||||
>;
|
||||
|
||||
// @public
|
||||
export function createRouteRef<
|
||||
TParams extends
|
||||
|
||||
@@ -140,13 +140,6 @@ describe('createFrontendPlugin', () => {
|
||||
expect(String(plugin)).toBe('Plugin{id=test}');
|
||||
});
|
||||
|
||||
it('should create an empty plugin with deprecated id option', () => {
|
||||
const plugin = createFrontendPlugin({ id: 'test' });
|
||||
|
||||
expect(plugin).toBeDefined();
|
||||
expect(String(plugin)).toBe('Plugin{id=test}');
|
||||
});
|
||||
|
||||
it('should create a plugin with extension instances', async () => {
|
||||
const plugin = createFrontendPlugin({
|
||||
pluginId: 'test',
|
||||
|
||||
@@ -147,49 +147,9 @@ export function createFrontendPlugin<
|
||||
TRoutes,
|
||||
TExternalRoutes,
|
||||
MakeSortedExtensionsMap<TExtensions[number], TId>
|
||||
>;
|
||||
/**
|
||||
* @public
|
||||
* @deprecated The `id` option is deprecated, use `pluginId` instead.
|
||||
*/
|
||||
export function createFrontendPlugin<
|
||||
TId extends string,
|
||||
TRoutes extends { [name in string]: RouteRef | SubRouteRef } = {},
|
||||
TExternalRoutes extends { [name in string]: ExternalRouteRef } = {},
|
||||
TExtensions extends readonly ExtensionDefinition[] = [],
|
||||
>(
|
||||
options: Omit<
|
||||
PluginOptions<TId, TRoutes, TExternalRoutes, TExtensions>,
|
||||
'pluginId'
|
||||
> & { id: string },
|
||||
): FrontendPlugin<
|
||||
TRoutes,
|
||||
TExternalRoutes,
|
||||
MakeSortedExtensionsMap<TExtensions[number], TId>
|
||||
>;
|
||||
export function createFrontendPlugin<
|
||||
TId extends string,
|
||||
TRoutes extends { [name in string]: RouteRef | SubRouteRef } = {},
|
||||
TExternalRoutes extends { [name in string]: ExternalRouteRef } = {},
|
||||
TExtensions extends readonly ExtensionDefinition[] = [],
|
||||
>(
|
||||
options:
|
||||
| PluginOptions<TId, TRoutes, TExternalRoutes, TExtensions>
|
||||
| (Omit<
|
||||
PluginOptions<TId, TRoutes, TExternalRoutes, TExtensions>,
|
||||
'pluginId'
|
||||
> & { id: string }),
|
||||
): FrontendPlugin<
|
||||
TRoutes,
|
||||
TExternalRoutes,
|
||||
MakeSortedExtensionsMap<TExtensions[number], TId>
|
||||
> {
|
||||
const pluginId = 'pluginId' in options ? options.pluginId : options.id;
|
||||
if (!pluginId) {
|
||||
throw new Error(
|
||||
"Either 'id' or 'pluginId' must be provided to createFrontendPlugin",
|
||||
);
|
||||
}
|
||||
const pluginId = options.pluginId;
|
||||
|
||||
const extensions = new Array<Extension<any>>();
|
||||
const extensionDefinitionsById = new Map<
|
||||
string,
|
||||
|
||||
Reference in New Issue
Block a user