Merge pull request #33147 from backstage/rugvip/simplify-extension-attach-to
Simplify the `ExtensionAttachTo` type
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/frontend-plugin-api': minor
|
||||
---
|
||||
|
||||
**BREAKING**: Simplified the `ExtensionAttachTo` type to only support a single attachment target. The array form for attaching to multiple extension points has been removed. Also removed the deprecated `ExtensionAttachToSpec` type alias.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ExtensionAttachToSpec } from '@backstage/frontend-plugin-api';
|
||||
import { ExtensionAttachTo } from '@backstage/frontend-plugin-api';
|
||||
import { EntityLayout, EntitySwitch, isKind } from '@backstage/plugin-catalog';
|
||||
import { JSX } from 'react';
|
||||
import { collectEntityPageContents } from './collectEntityPageContents';
|
||||
@@ -73,7 +73,7 @@ const otherTestContent = (
|
||||
function collect(element: JSX.Element) {
|
||||
const result = new Array<{
|
||||
id: string;
|
||||
attachTo: ExtensionAttachToSpec;
|
||||
attachTo: ExtensionAttachTo;
|
||||
}>();
|
||||
|
||||
collectEntityPageContents(element, {
|
||||
|
||||
@@ -149,7 +149,7 @@ describe('buildAppTree', () => {
|
||||
attachTo: [
|
||||
{ id: 'a', input: 'x' },
|
||||
{ id: 'b', input: 'x' },
|
||||
],
|
||||
] as any,
|
||||
},
|
||||
{
|
||||
...baseSpec,
|
||||
@@ -157,7 +157,7 @@ describe('buildAppTree', () => {
|
||||
attachTo: [
|
||||
{ id: 'b', input: 'x' },
|
||||
{ id: 'c', input: 'x' },
|
||||
],
|
||||
] as any,
|
||||
},
|
||||
],
|
||||
collector,
|
||||
|
||||
@@ -921,7 +921,7 @@ export interface Extension<TConfig, TConfigInput = TConfig> {
|
||||
// (undocumented)
|
||||
$$type: '@backstage/Extension';
|
||||
// (undocumented)
|
||||
readonly attachTo: ExtensionAttachToSpec;
|
||||
readonly attachTo: ExtensionAttachTo;
|
||||
// (undocumented)
|
||||
readonly configSchema?: PortableSchema<TConfig, TConfigInput>;
|
||||
// (undocumented)
|
||||
@@ -931,18 +931,10 @@ export interface Extension<TConfig, TConfigInput = TConfig> {
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export type ExtensionAttachTo =
|
||||
| {
|
||||
id: string;
|
||||
input: string;
|
||||
}
|
||||
| Array<{
|
||||
id: string;
|
||||
input: string;
|
||||
}>;
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
export type ExtensionAttachToSpec = ExtensionAttachTo;
|
||||
export type ExtensionAttachTo = {
|
||||
id: string;
|
||||
input: string;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ExtensionBlueprint<
|
||||
|
||||
@@ -57,7 +57,6 @@ export {
|
||||
export {
|
||||
type Extension,
|
||||
type ExtensionAttachTo,
|
||||
type ExtensionAttachToSpec,
|
||||
} from './resolveExtensionDefinition';
|
||||
export {
|
||||
type ExtensionDataContainer,
|
||||
|
||||
@@ -30,21 +30,13 @@ import {
|
||||
} from '@internal/frontend';
|
||||
|
||||
/** @public */
|
||||
export type ExtensionAttachTo =
|
||||
| { id: string; input: string }
|
||||
| Array<{ id: string; input: string }>;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link ExtensionAttachTo} instead.
|
||||
* @public
|
||||
*/
|
||||
export type ExtensionAttachToSpec = ExtensionAttachTo;
|
||||
export type ExtensionAttachTo = { id: string; input: string };
|
||||
|
||||
/** @public */
|
||||
export interface Extension<TConfig, TConfigInput = TConfig> {
|
||||
$$type: '@backstage/Extension';
|
||||
readonly id: string;
|
||||
readonly attachTo: ExtensionAttachToSpec;
|
||||
readonly attachTo: ExtensionAttachTo;
|
||||
readonly disabled: boolean;
|
||||
readonly configSchema?: PortableSchema<TConfig, TConfigInput>;
|
||||
}
|
||||
@@ -151,7 +143,7 @@ function resolveExtensionId(
|
||||
function resolveAttachTo(
|
||||
attachTo: ExtensionDefinitionAttachTo | ExtensionDefinitionAttachTo[],
|
||||
namespace?: string,
|
||||
): ExtensionAttachToSpec {
|
||||
): ExtensionAttachTo | ExtensionAttachTo[] {
|
||||
const resolveSpec = (
|
||||
spec: ExtensionDefinitionAttachTo,
|
||||
): { id: string; input: string } => {
|
||||
@@ -213,7 +205,7 @@ export function resolveExtensionDefinition<
|
||||
|
||||
return {
|
||||
...rest,
|
||||
attachTo: resolveAttachTo(attachTo, namespace),
|
||||
attachTo: resolveAttachTo(attachTo, namespace) as ExtensionAttachTo,
|
||||
$$type: '@backstage/Extension',
|
||||
version: internalDefinition.version,
|
||||
id,
|
||||
|
||||
Reference in New Issue
Block a user