From dc7ae8b20a902017dea554e9d96a3c2ed32db52c Mon Sep 17 00:00:00 2001 From: secustor Date: Thu, 25 Jan 2024 16:12:42 +0100 Subject: [PATCH 1/4] fix(plugins/home/FeatureDocsCard): fall back to metadata.name if no title has been supplied Signed-off-by: secustor --- .changeset/nasty-shirts-look.md | 5 +++++ .../home/src/homePageComponents/FeaturedDocsCard/Content.tsx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/nasty-shirts-look.md diff --git a/.changeset/nasty-shirts-look.md b/.changeset/nasty-shirts-look.md new file mode 100644 index 0000000000..2742ebd1f6 --- /dev/null +++ b/.changeset/nasty-shirts-look.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-home': patch +--- + +Fall back to metadata.name if no metadata.title has been defined diff --git a/plugins/home/src/homePageComponents/FeaturedDocsCard/Content.tsx b/plugins/home/src/homePageComponents/FeaturedDocsCard/Content.tsx index eb8d78b0cc..21ed43003b 100644 --- a/plugins/home/src/homePageComponents/FeaturedDocsCard/Content.tsx +++ b/plugins/home/src/homePageComponents/FeaturedDocsCard/Content.tsx @@ -116,7 +116,7 @@ export const Content = (props: FeaturedDocsCardProps): JSX.Element => { }/` } > - {d.metadata.title} + {d.metadata.title ?? d.metadata.name} {d.metadata.description && ( From 9fe9285b07f696ae961d17bdfd9389a06b70ebd1 Mon Sep 17 00:00:00 2001 From: secustor Date: Thu, 25 Jan 2024 16:46:18 +0100 Subject: [PATCH 2/4] feat(plugins/home/FeatureDocsCard): use EntityDisplayName rather then data direct Signed-off-by: secustor --- .changeset/nasty-shirts-look.md | 4 ++-- .../src/homePageComponents/FeaturedDocsCard/Content.tsx | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.changeset/nasty-shirts-look.md b/.changeset/nasty-shirts-look.md index 2742ebd1f6..2a6e2d9c19 100644 --- a/.changeset/nasty-shirts-look.md +++ b/.changeset/nasty-shirts-look.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-home': patch +'@backstage/plugin-home': minor --- -Fall back to metadata.name if no metadata.title has been defined +Use EntityDisplayName JSX element entity information directly for FeaturedDocsCard. diff --git a/plugins/home/src/homePageComponents/FeaturedDocsCard/Content.tsx b/plugins/home/src/homePageComponents/FeaturedDocsCard/Content.tsx index 21ed43003b..a7ba4d5e9b 100644 --- a/plugins/home/src/homePageComponents/FeaturedDocsCard/Content.tsx +++ b/plugins/home/src/homePageComponents/FeaturedDocsCard/Content.tsx @@ -23,11 +23,16 @@ import { Progress, ErrorPanel, } from '@backstage/core-components'; -import { catalogApiRef, CatalogApi } from '@backstage/plugin-catalog-react'; +import { + catalogApiRef, + CatalogApi, + EntityDisplayName, +} from '@backstage/plugin-catalog-react'; import { useApi } from '@backstage/core-plugin-api'; import { EntityFilterQuery } from '@backstage/catalog-client'; import { makeStyles, Typography } from '@material-ui/core'; +import { stringifyEntityRef } from '@backstage/catalog-model'; /** * Props customizing the component. @@ -116,7 +121,7 @@ export const Content = (props: FeaturedDocsCardProps): JSX.Element => { }/` } > - {d.metadata.title ?? d.metadata.name} + {d.metadata.description && ( From 4461c556c63e914c710305d60bec1963e9d0f367 Mon Sep 17 00:00:00 2001 From: secustor Date: Thu, 25 Jan 2024 18:09:50 +0100 Subject: [PATCH 3/4] adapt test Signed-off-by: secustor --- .../src/homePageComponents/FeaturedDocsCard/Content.test.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/home/src/homePageComponents/FeaturedDocsCard/Content.test.tsx b/plugins/home/src/homePageComponents/FeaturedDocsCard/Content.test.tsx index 427a1484d5..c49b41eb18 100644 --- a/plugins/home/src/homePageComponents/FeaturedDocsCard/Content.test.tsx +++ b/plugins/home/src/homePageComponents/FeaturedDocsCard/Content.test.tsx @@ -66,8 +66,7 @@ describe('', () => { }, ); const docsCardContent = getByTestId('docs-card-content'); - const docsEntity = getByText('Getting Started Docs'); - + const docsEntity = getByText('getting-started-with-idp'); expect(docsCardContent).toContainElement(docsEntity); }); }); From ce6e00d1990d52604cbc9ef3e324b5aca262d43c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 6 Feb 2024 15:39:47 +0100 Subject: [PATCH 4/4] Update .changeset/nasty-shirts-look.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/nasty-shirts-look.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/nasty-shirts-look.md b/.changeset/nasty-shirts-look.md index 2a6e2d9c19..32213ee219 100644 --- a/.changeset/nasty-shirts-look.md +++ b/.changeset/nasty-shirts-look.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-home': minor +'@backstage/plugin-home': patch --- Use EntityDisplayName JSX element entity information directly for FeaturedDocsCard.