diff --git a/plugins/catalog-react/src/alpha/converters/convertLegacyEntityCardExtension.tsx b/plugins/catalog-react/src/alpha/converters/convertLegacyEntityCardExtension.tsx index 25ea778f0d..afe5211d1b 100644 --- a/plugins/catalog-react/src/alpha/converters/convertLegacyEntityCardExtension.tsx +++ b/plugins/catalog-react/src/alpha/converters/convertLegacyEntityCardExtension.tsx @@ -15,9 +15,8 @@ */ import { compatWrapper } from '@backstage/core-compat-api'; -import { getComponentData } from '@backstage/core-plugin-api'; +import { BackstagePlugin, getComponentData } from '@backstage/core-plugin-api'; import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; -import kebabCase from 'lodash/kebabCase'; import React, { ComponentType } from 'react'; import { EntityCardBlueprint } from '../blueprints'; @@ -38,12 +37,27 @@ export function convertLegacyEntityCardExtension( throw new Error('Extension has no name'); } - const match = extName.match(/^Entity(.*)Card$/); - const name = match?.[1] ?? extName; - const kebabName = kebabCase(name); + const plugin = getComponentData(element, 'core.plugin'); + const pluginId = plugin?.getId(); + + const match = extName.match(/^Entity(.*)Content$/); + const infix = match?.[1] ?? extName; + + let name: string | undefined = infix; + if ( + pluginId && + name + .toLocaleLowerCase('en-US') + .startsWith(pluginId.toLocaleLowerCase('en-US')) + ) { + name = name.slice(pluginId.length); + if (!name) { + name = undefined; + } + } return EntityCardBlueprint.make({ - name: overrides?.name ?? kebabName, + name: overrides?.name ?? name, params: { filter: overrides?.filter, loader: async () => compatWrapper(element), diff --git a/plugins/catalog-react/src/alpha/converters/convertLegacyEntityContentExtension.tsx b/plugins/catalog-react/src/alpha/converters/convertLegacyEntityContentExtension.tsx index ea452a4d24..a44a6281da 100644 --- a/plugins/catalog-react/src/alpha/converters/convertLegacyEntityContentExtension.tsx +++ b/plugins/catalog-react/src/alpha/converters/convertLegacyEntityContentExtension.tsx @@ -19,6 +19,7 @@ import { convertLegacyRouteRef, } from '@backstage/core-compat-api'; import { + BackstagePlugin, getComponentData, RouteRef as LegacyRouteRef, } from '@backstage/core-plugin-api'; @@ -52,16 +53,31 @@ export function convertLegacyEntityContentExtension( 'core.mountPoint', ); + const plugin = getComponentData(element, 'core.plugin'); + const pluginId = plugin?.getId(); + const match = extName.match(/^Entity(.*)Content$/); - const name = match?.[1] ?? extName; - const kebabName = kebabCase(name); + const infix = match?.[1] ?? extName; + + let name: string | undefined = infix; + if ( + pluginId && + name + .toLocaleLowerCase('en-US') + .startsWith(pluginId.toLocaleLowerCase('en-US')) + ) { + name = name.slice(pluginId.length); + if (!name) { + name = undefined; + } + } return EntityContentBlueprint.make({ - name: overrides?.name ?? kebabName, + name: overrides?.name ?? name, params: { filter: overrides?.filter, - defaultPath: overrides?.defaultPath ?? `/${kebabName}`, - defaultTitle: overrides?.defaultTitle ?? startCase(name), + defaultPath: overrides?.defaultPath ?? `/${kebabCase(infix)}`, + defaultTitle: overrides?.defaultTitle ?? startCase(infix), routeRef: mountPoint && convertLegacyRouteRef(mountPoint), loader: async () => compatWrapper(element), },