From 95f81d56a887a588a2780d9c11f23232d46bbaac Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Mon, 19 Sep 2022 16:31:54 +0200 Subject: [PATCH] Provide custom links in EntityRefLinks Signed-off-by: bnechyporenko --- .../src/components/EntityRefLink/EntityRefLinks.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx index 30dda011d4..054dd0350c 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.tsx @@ -1,5 +1,5 @@ /* - * Copyright 2020 The Backstage Authors + * Copyright 2022 The Backstage Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import { Entity, CompoundEntityRef } from '@backstage/catalog-model'; import React from 'react'; import { EntityRefLink } from './EntityRefLink'; @@ -27,6 +26,7 @@ import { LinkProps } from '@backstage/core-components'; export type EntityRefLinksProps = { entityRefs: (string | Entity | CompoundEntityRef)[]; defaultKind?: string; + titleFn?: (r: string | Entity | CompoundEntityRef) => string; } & Omit; /** @@ -35,7 +35,7 @@ export type EntityRefLinksProps = { * @public */ export function EntityRefLinks(props: EntityRefLinksProps) { - const { entityRefs, defaultKind, ...linkProps } = props; + const { entityRefs, defaultKind, titleFn, ...linkProps } = props; return ( <> {entityRefs.map((r, i) => ( @@ -45,6 +45,7 @@ export function EntityRefLinks(props: EntityRefLinksProps) { {...linkProps} entityRef={r} defaultKind={defaultKind} + title={titleFn ? titleFn(r) : undefined} /> ))}