Skip to content

Commit

Permalink
Add support for string refs to the EntityRefLinks component
Browse files Browse the repository at this point in the history
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
  • Loading branch information
freben committed Mar 18, 2022
1 parent ffaaec5 commit a496cee
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-snakes-float.md
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-react': patch
---

Add support for string refs to the `EntityRefLinks` component
8 changes: 2 additions & 6 deletions plugins/catalog-react/api-report.md
Expand Up @@ -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'>;

Expand Down
Expand Up @@ -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'>;

Expand All @@ -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>
))}
</>
);
}

0 comments on commit a496cee

Please sign in to comment.