diff --git a/plugins/catalog/src/data/component.ts b/plugins/catalog/src/data/component.ts index 81299762a4..73b349391b 100644 --- a/plugins/catalog/src/data/component.ts +++ b/plugins/catalog/src/data/component.ts @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import React from 'react'; +import { ReactNode } from 'react'; import { Location } from '@backstage/catalog-model'; export type Component = { name: string; kind: string; - description: React.ReactNode; + description: ReactNode; location?: Location; }; diff --git a/plugins/catalog/src/data/utils.tsx b/plugins/catalog/src/data/utils.tsx index 78b29dae04..93d28f5ca2 100644 --- a/plugins/catalog/src/data/utils.tsx +++ b/plugins/catalog/src/data/utils.tsx @@ -29,7 +29,14 @@ const DescriptionWrapper = styled('span')({ alignItems: 'center', }); -const createEditLink = (url: string): string => url.replace('blob', 'edit'); +const createEditLink = (location: Location): string => { + switch (location.type) { + case 'github': + return location.target.replace('/blob/', '/edit/'); + default: + return location.target; + } +}; export function entityToComponent( envelope: Entity, @@ -42,7 +49,7 @@ export function entityToComponent( {envelope.metadata?.annotations?.description ?? 'placeholder'} {location?.target ? ( - +