Bazaar: Link to the member user catalog entity

If the optional user entity ref is available the link for a member will
point to the backstage catalog page for the user. Otherwise it will
default to the current "https://github.com/${displayName}".

Signed-off-by: Niklas Aronsson <niklasar@axis.com>
This commit is contained in:
Niklas Aronsson
2022-09-26 09:18:46 +02:00
parent 8554533546
commit c0352bbc69
7 changed files with 23 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-bazaar': patch
---
Link to the user catalog entity of a member
+1 -1
View File
@@ -2,7 +2,7 @@
'@backstage/plugin-bazaar-backend': minor
---
**BREAKING** The bazaar-backend createRouter now requires that the `identityApi` is passed to the router.
**BREAKING** The bazaar-backend `createRouter` now requires that the `identityApi` is passed to the router.
These changes are **required** to `packages/backend/src/plugins/bazaar.ts`
+3
View File
@@ -5,6 +5,7 @@
```ts
import { Config } from '@backstage/config';
import express from 'express';
import { IdentityApi } from '@backstage/plugin-auth-node';
import { Logger } from 'winston';
import { PluginDatabaseManager } from '@backstage/backend-common';
@@ -18,6 +19,8 @@ export interface RouterOptions {
// (undocumented)
database: PluginDatabaseManager;
// (undocumented)
identity: IdentityApi;
// (undocumented)
logger: Logger;
}
@@ -23,8 +23,11 @@ import {
Typography,
GridSize,
} from '@material-ui/core';
import { parseEntityRef } from '@backstage/catalog-model';
import { Avatar, Link } from '@backstage/core-components';
import { useRouteRef } from '@backstage/core-plugin-api';
import { AboutField } from '@backstage/plugin-catalog';
import { entityRouteRef } from '@backstage/plugin-catalog-react';
import { StatusTag } from '../StatusTag';
import { Member, BazaarProject } from '../../types';
@@ -49,6 +52,7 @@ export const CardContentFields = ({
membersSize,
}: Props) => {
const classes = useStyles();
const catalogEntityRoute = useRouteRef(entityRouteRef);
return (
<div>
@@ -111,8 +115,14 @@ export const CardContentFields = ({
/>
<Link
className={classes.break}
to={`http://github.com/${member.userId}`}
target="_blank"
to={
member.userRef
? `${catalogEntityRoute(
parseEntityRef(member.userRef),
)}`
: `http://github.com/${member.userId}`
}
>
{member?.userId}
</Link>
+1
View File
@@ -19,6 +19,7 @@ export type Member = {
userId: string;
joinDate?: string;
picture?: string;
userRef?: string;
};
export type Status = 'ongoing' | 'proposed';
+1
View File
@@ -37,6 +37,7 @@ export const parseMember = (member: any): Member => {
return {
itemId: member.item_id,
userId: member.user_id,
userRef: member.user_ref,
joinDate: member.join_date,
picture: member.picture,
} as Member;
+1
View File
@@ -4349,6 +4349,7 @@ __metadata:
"@backstage/backend-test-utils": "workspace:^"
"@backstage/cli": "workspace:^"
"@backstage/config": "workspace:^"
"@backstage/plugin-auth-node": "workspace:^"
"@types/express": ^4.17.6
express: ^4.17.1
express-promise-router: ^4.1.0