From 64cbca78393b7cd5cda37c8cb8dd18f41f8cd56d Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Wed, 2 Feb 2022 07:07:44 -0600 Subject: [PATCH] Added description to UserProfileCard Signed-off-by: Andre Wanlin --- .changeset/ninety-brooms-lay.md | 5 +++++ .../User/UserProfileCard/UserProfileCard.stories.tsx | 2 ++ .../Cards/User/UserProfileCard/UserProfileCard.test.tsx | 2 ++ .../Cards/User/UserProfileCard/UserProfileCard.tsx | 8 ++++++-- 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .changeset/ninety-brooms-lay.md diff --git a/.changeset/ninety-brooms-lay.md b/.changeset/ninety-brooms-lay.md new file mode 100644 index 0000000000..4db03bcabc --- /dev/null +++ b/.changeset/ninety-brooms-lay.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-org': patch +--- + +The description from `metadata.description` will now show as the subheader on the UserProfileCard in the same way as the GroupProfileCard diff --git a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx index aecc401f52..0cb3987c77 100644 --- a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx +++ b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx @@ -40,6 +40,7 @@ const defaultEntity: UserEntity = { kind: 'User', metadata: { name: 'guest', + description: 'Description for guest', }, spec: { profile: { @@ -70,6 +71,7 @@ const noImageEntity: UserEntity = { kind: 'User', metadata: { name: 'guest', + description: 'Description for guest', }, spec: { profile: { diff --git a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.test.tsx b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.test.tsx index 743ed987fa..7b9904954f 100644 --- a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.test.tsx +++ b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.test.tsx @@ -29,6 +29,7 @@ describe('UserSummary Test', () => { kind: 'User', metadata: { name: 'calum.leavy', + description: 'Super awesome human', }, spec: { profile: { @@ -73,5 +74,6 @@ describe('UserSummary Test', () => { 'href', '/catalog/default/group/ExampleGroup', ); + expect(rendered.getByText('Super awesome human')).toBeInTheDocument(); }); }); diff --git a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx index 298819ed09..0997e0a4d8 100644 --- a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx +++ b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx @@ -61,7 +61,7 @@ export const UserProfileCard = ({ } const { - metadata: { name: metaName }, + metadata: { name: metaName, description }, spec: { profile }, } = user; const displayName = profile?.displayName ?? metaName; @@ -71,7 +71,11 @@ export const UserProfileCard = ({ }); return ( - } variant={variant}> + } + subheader={description} + variant={variant} + >