frontend-plugin-api: refactor extension "at" option to "attachTo"
Co-authored-by: Camila Belo <camilaibs@gmail.com> Co-authored-by: Fredrik Adelöw <freben@gmail.com> Co-authored-by: Vincenzo Scamporlino <vincenzos@spotify.com> Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -33,7 +33,7 @@ describe('createApiExtension', () => {
|
||||
expect(extension).toEqual({
|
||||
$$type: '@backstage/Extension',
|
||||
id: 'apis.test',
|
||||
at: 'core/apis',
|
||||
attachTo: { id: 'core', input: 'apis' },
|
||||
disabled: false,
|
||||
configSchema: undefined,
|
||||
inputs: {},
|
||||
@@ -67,7 +67,7 @@ describe('createApiExtension', () => {
|
||||
expect(extension).toEqual({
|
||||
$$type: '@backstage/Extension',
|
||||
id: 'apis.test',
|
||||
at: 'core/apis',
|
||||
attachTo: { id: 'core', input: 'apis' },
|
||||
disabled: false,
|
||||
configSchema: undefined,
|
||||
inputs: {},
|
||||
|
||||
@@ -51,7 +51,7 @@ export function createApiExtension<
|
||||
|
||||
return createExtension({
|
||||
id: `apis.${apiRef.id}`,
|
||||
at: 'core/apis',
|
||||
attachTo: { id: 'core', input: 'apis' },
|
||||
inputs: extensionInputs,
|
||||
configSchema,
|
||||
output: {
|
||||
|
||||
@@ -31,7 +31,7 @@ export function createNavItemExtension(options: {
|
||||
const { id, routeRef, title, icon } = options;
|
||||
return createExtension({
|
||||
id,
|
||||
at: 'core.nav/items',
|
||||
attachTo: { id: 'core.nav', input: 'items' },
|
||||
configSchema: createSchemaFromZod(z =>
|
||||
z.object({
|
||||
title: z.string().default(title),
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('createPageExtension', () => {
|
||||
).toEqual({
|
||||
$$type: '@backstage/Extension',
|
||||
id: 'test',
|
||||
at: 'core.routes/routes',
|
||||
attachTo: { id: 'core.routes', input: 'routes' },
|
||||
configSchema: expect.anything(),
|
||||
disabled: false,
|
||||
inputs: {},
|
||||
@@ -50,7 +50,7 @@ describe('createPageExtension', () => {
|
||||
expect(
|
||||
createPageExtension({
|
||||
id: 'test',
|
||||
at: 'other/place',
|
||||
attachTo: { id: 'other', input: 'place' },
|
||||
disabled: true,
|
||||
configSchema,
|
||||
inputs: {
|
||||
@@ -63,7 +63,7 @@ describe('createPageExtension', () => {
|
||||
).toEqual({
|
||||
$$type: '@backstage/Extension',
|
||||
id: 'test',
|
||||
at: 'other/place',
|
||||
attachTo: { id: 'other', input: 'place' },
|
||||
configSchema: expect.anything(),
|
||||
disabled: true,
|
||||
inputs: {
|
||||
@@ -88,7 +88,7 @@ describe('createPageExtension', () => {
|
||||
).toEqual({
|
||||
$$type: '@backstage/Extension',
|
||||
id: 'test',
|
||||
at: 'core.routes/routes',
|
||||
attachTo: { id: 'core.routes', input: 'routes' },
|
||||
configSchema: expect.anything(),
|
||||
disabled: false,
|
||||
inputs: {},
|
||||
|
||||
@@ -44,7 +44,7 @@ export function createPageExtension<
|
||||
}
|
||||
) & {
|
||||
id: string;
|
||||
at?: string;
|
||||
attachTo?: { id: string; input: string };
|
||||
disabled?: boolean;
|
||||
inputs?: TInputs;
|
||||
routeRef?: RouteRef;
|
||||
@@ -63,7 +63,7 @@ export function createPageExtension<
|
||||
|
||||
return createExtension({
|
||||
id: options.id,
|
||||
at: options.at ?? 'core.routes/routes',
|
||||
attachTo: options.attachTo ?? { id: 'core.routes', input: 'routes' },
|
||||
disabled: options.disabled,
|
||||
output: {
|
||||
element: coreExtensionData.reactElement,
|
||||
|
||||
@@ -21,7 +21,7 @@ import { AppTheme } from '@backstage/core-plugin-api';
|
||||
export function createThemeExtension(theme: AppTheme) {
|
||||
return createExtension({
|
||||
id: `themes.${theme.id}`,
|
||||
at: 'core/themes',
|
||||
attachTo: { id: 'core', input: 'themes' },
|
||||
output: {
|
||||
theme: coreExtensionData.theme,
|
||||
},
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('createExtension', () => {
|
||||
it('should create an extension with a simple output', () => {
|
||||
const extension = createExtension({
|
||||
id: 'test',
|
||||
at: 'root',
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
output: {
|
||||
foo: stringData,
|
||||
},
|
||||
@@ -56,7 +56,7 @@ describe('createExtension', () => {
|
||||
it('should create an extension with a some optional output', () => {
|
||||
const extension = createExtension({
|
||||
id: 'test',
|
||||
at: 'root',
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
output: {
|
||||
foo: stringData,
|
||||
bar: stringData.optional(),
|
||||
@@ -94,7 +94,7 @@ describe('createExtension', () => {
|
||||
it('should create an extension with input', () => {
|
||||
const extension = createExtension({
|
||||
id: 'test',
|
||||
at: 'root',
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
inputs: {
|
||||
mixed: createExtensionInput({
|
||||
required: stringData,
|
||||
|
||||
@@ -80,7 +80,7 @@ export interface CreateExtensionOptions<
|
||||
TConfig,
|
||||
> {
|
||||
id: string;
|
||||
at: string;
|
||||
attachTo: { id: string; input: string };
|
||||
disabled?: boolean;
|
||||
inputs?: TInputs;
|
||||
output: TOutput;
|
||||
@@ -97,7 +97,7 @@ export interface CreateExtensionOptions<
|
||||
export interface Extension<TConfig> {
|
||||
$$type: '@backstage/Extension';
|
||||
id: string;
|
||||
at: string;
|
||||
attachTo: { id: string; input: string };
|
||||
disabled: boolean;
|
||||
inputs: AnyExtensionInputMap;
|
||||
output: AnyExtensionDataMap;
|
||||
|
||||
@@ -30,7 +30,7 @@ const nameExtensionDataRef = createExtensionDataRef<string>('name');
|
||||
|
||||
const TechRadarPage = createExtension({
|
||||
id: 'plugin.techradar.page',
|
||||
at: 'test.output/names',
|
||||
attachTo: { id: 'test.output', input: 'names' },
|
||||
output: {
|
||||
name: nameExtensionDataRef,
|
||||
},
|
||||
@@ -41,7 +41,7 @@ const TechRadarPage = createExtension({
|
||||
|
||||
const CatalogPage = createExtension({
|
||||
id: 'plugin.catalog.page',
|
||||
at: 'test.output/names',
|
||||
attachTo: { id: 'test.output', input: 'names' },
|
||||
output: {
|
||||
name: nameExtensionDataRef,
|
||||
},
|
||||
@@ -55,7 +55,7 @@ const CatalogPage = createExtension({
|
||||
|
||||
const TechDocsAddon = createExtension({
|
||||
id: 'plugin.techdocs.addon.example',
|
||||
at: 'plugin.techdocs.page/addons',
|
||||
attachTo: { id: 'plugin.techdocs.page', input: 'addons' },
|
||||
output: {
|
||||
name: nameExtensionDataRef,
|
||||
},
|
||||
@@ -69,7 +69,7 @@ const TechDocsAddon = createExtension({
|
||||
|
||||
const TechDocsPage = createExtension({
|
||||
id: 'plugin.techdocs.page',
|
||||
at: 'test.output/names',
|
||||
attachTo: { id: 'test.output', input: 'names' },
|
||||
inputs: {
|
||||
addons: createExtensionInput({
|
||||
name: nameExtensionDataRef,
|
||||
@@ -85,7 +85,7 @@ const TechDocsPage = createExtension({
|
||||
|
||||
const outputExtension = createExtension({
|
||||
id: 'test.output',
|
||||
at: 'root',
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
inputs: {
|
||||
names: createExtensionInput({
|
||||
name: nameExtensionDataRef,
|
||||
|
||||
Reference in New Issue
Block a user