Merge pull request #10306 from backstage/freben/strings-are-refs-too

Add support for string refs to the EntityRefLinks component
This commit is contained in:
Fredrik Adelöw
2022-03-18 12:48:35 +01:00
committed by GitHub
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>
))}
</>
);
}