From c0352bbc690259b8a718c9ecb8a820f1993603a4 Mon Sep 17 00:00:00 2001 From: Niklas Aronsson Date: Mon, 26 Sep 2022 09:18:46 +0200 Subject: [PATCH] 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 --- .changeset/large-jars-fry.md | 5 +++++ .changeset/tough-seahorses-learn.md | 2 +- plugins/bazaar-backend/api-report.md | 3 +++ .../CardContentFields/CardContentFields.tsx | 12 +++++++++++- plugins/bazaar/src/types.ts | 1 + plugins/bazaar/src/util/parseMethods.ts | 1 + yarn.lock | 1 + 7 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .changeset/large-jars-fry.md diff --git a/.changeset/large-jars-fry.md b/.changeset/large-jars-fry.md new file mode 100644 index 0000000000..0da3f4302b --- /dev/null +++ b/.changeset/large-jars-fry.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-bazaar': patch +--- + +Link to the user catalog entity of a member diff --git a/.changeset/tough-seahorses-learn.md b/.changeset/tough-seahorses-learn.md index f0b6bcb70a..518b6b6967 100644 --- a/.changeset/tough-seahorses-learn.md +++ b/.changeset/tough-seahorses-learn.md @@ -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` diff --git a/plugins/bazaar-backend/api-report.md b/plugins/bazaar-backend/api-report.md index d62453d156..1ee889c04a 100644 --- a/plugins/bazaar-backend/api-report.md +++ b/plugins/bazaar-backend/api-report.md @@ -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; } diff --git a/plugins/bazaar/src/components/CardContentFields/CardContentFields.tsx b/plugins/bazaar/src/components/CardContentFields/CardContentFields.tsx index 6c6ce1bb3e..641ae97f95 100644 --- a/plugins/bazaar/src/components/CardContentFields/CardContentFields.tsx +++ b/plugins/bazaar/src/components/CardContentFields/CardContentFields.tsx @@ -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 (
@@ -111,8 +115,14 @@ export const CardContentFields = ({ /> {member?.userId} diff --git a/plugins/bazaar/src/types.ts b/plugins/bazaar/src/types.ts index ec3996d1e2..e698f21264 100644 --- a/plugins/bazaar/src/types.ts +++ b/plugins/bazaar/src/types.ts @@ -19,6 +19,7 @@ export type Member = { userId: string; joinDate?: string; picture?: string; + userRef?: string; }; export type Status = 'ongoing' | 'proposed'; diff --git a/plugins/bazaar/src/util/parseMethods.ts b/plugins/bazaar/src/util/parseMethods.ts index 1b4ebfd308..b32c5d42d3 100644 --- a/plugins/bazaar/src/util/parseMethods.ts +++ b/plugins/bazaar/src/util/parseMethods.ts @@ -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; diff --git a/yarn.lock b/yarn.lock index c2019f86ad..3f93da2b99 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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