Add support for string refs to the EntityRefLinks component

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-03-18 11:50:53 +01:00
parent ffaaec5950
commit a496cee4d1
3 changed files with 25 additions and 21 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-react': patch
---
Add support for string refs to the `EntityRefLinks` component
+2 -6
View File
@@ -261,15 +261,11 @@ export type EntityRefLinkProps = {
} & Omit<LinkProps, 'to'>;
// @public
export const EntityRefLinks: ({
entityRefs,
defaultKind,
...linkProps
}: EntityRefLinksProps) => JSX.Element;
export function EntityRefLinks(props: EntityRefLinksProps): JSX.Element;
// @public
export type EntityRefLinksProps = {
entityRefs: (Entity | CompoundEntityRef)[];
entityRefs: (string | Entity | CompoundEntityRef)[];
defaultKind?: string;
} & Omit<LinkProps, 'to'>;
@@ -25,7 +25,7 @@ import { LinkProps } from '@backstage/core-components';
* @public
*/
export type EntityRefLinksProps = {
entityRefs: (Entity | CompoundEntityRef)[];
entityRefs: (string | Entity | CompoundEntityRef)[];
defaultKind?: string;
} & Omit<LinkProps, 'to'>;
@@ -34,17 +34,20 @@ export type EntityRefLinksProps = {
*
* @public
*/
export const EntityRefLinks = ({
entityRefs,
defaultKind,
...linkProps
}: EntityRefLinksProps) => (
<>
{entityRefs.map((r, i) => (
<React.Fragment key={i}>
{i > 0 && ', '}
<EntityRefLink {...linkProps} entityRef={r} defaultKind={defaultKind} />
</React.Fragment>
))}
</>
);
export function EntityRefLinks(props: EntityRefLinksProps) {
const { entityRefs, defaultKind, ...linkProps } = props;
return (
<>
{entityRefs.map((r, i) => (
<React.Fragment key={i}>
{i > 0 && ', '}
<EntityRefLink
{...linkProps}
entityRef={r}
defaultKind={defaultKind}
/>
</React.Fragment>
))}
</>
);
}