From 03f478fe0ae79694e554a90b1e915c8121cbccbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20=C5=A0neberger?= Date: Fri, 18 Nov 2022 11:44:14 +0100 Subject: [PATCH 1/4] Use pluralize for catalog kind header component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marek Šneberger --- plugins/catalog/package.json | 1 + .../src/components/CatalogKindHeader/CatalogKindHeader.tsx | 3 ++- yarn.lock | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/catalog/package.json b/plugins/catalog/package.json index 1528737aac..244aab8626 100644 --- a/plugins/catalog/package.json +++ b/plugins/catalog/package.json @@ -49,6 +49,7 @@ "@material-ui/lab": "4.0.0-alpha.57", "history": "^5.0.0", "lodash": "^4.17.21", + "pluralize": "^8.0.0", "react-helmet": "6.1.0", "react-use": "^17.2.4", "zen-observable": "^0.9.0" diff --git a/plugins/catalog/src/components/CatalogKindHeader/CatalogKindHeader.tsx b/plugins/catalog/src/components/CatalogKindHeader/CatalogKindHeader.tsx index b0aaeae658..bb9e98d9c3 100644 --- a/plugins/catalog/src/components/CatalogKindHeader/CatalogKindHeader.tsx +++ b/plugins/catalog/src/components/CatalogKindHeader/CatalogKindHeader.tsx @@ -31,6 +31,7 @@ import { } from '@backstage/plugin-catalog-react'; import useAsync from 'react-use/lib/useAsync'; import { useApi } from '@backstage/core-plugin-api'; +import pluralize from 'pluralize'; const useStyles = makeStyles((theme: Theme) => createStyles({ @@ -132,7 +133,7 @@ export function CatalogKindHeader(props: CatalogKindHeaderProps) { > {Object.keys(options).map(kind => ( - {`${options[kind]}s`} + {`${pluralize(options[kind])}`} ))} diff --git a/yarn.lock b/yarn.lock index 1a5617c798..0f497b5abe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4750,6 +4750,7 @@ __metadata: cross-fetch: ^3.1.5 history: ^5.0.0 lodash: ^4.17.21 + pluralize: ^8.0.0 react-helmet: 6.1.0 react-use: ^17.2.4 zen-observable: ^0.9.0 From 387d1d5218bfa01229a95e532f64c2d7c2cbfae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20=C5=A0neberger?= Date: Fri, 18 Nov 2022 13:08:12 +0100 Subject: [PATCH 2/4] Add changeset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marek Šneberger --- .changeset/thin-donuts-join.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/thin-donuts-join.md diff --git a/.changeset/thin-donuts-join.md b/.changeset/thin-donuts-join.md new file mode 100644 index 0000000000..10e1030801 --- /dev/null +++ b/.changeset/thin-donuts-join.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': patch +--- + +Add `pluralize()` to the catalog kind header component. From 429812a4233153482ab7c61076d4d99740465700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20=C5=A0neberger?= Date: Fri, 18 Nov 2022 13:25:52 +0100 Subject: [PATCH 3/4] Test pluralized Technology kind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marek Šneberger --- .../components/CatalogKindHeader/CatalogKindHeader.test.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/catalog/src/components/CatalogKindHeader/CatalogKindHeader.test.tsx b/plugins/catalog/src/components/CatalogKindHeader/CatalogKindHeader.test.tsx index 9f68252ca7..f511f58c58 100644 --- a/plugins/catalog/src/components/CatalogKindHeader/CatalogKindHeader.test.tsx +++ b/plugins/catalog/src/components/CatalogKindHeader/CatalogKindHeader.test.tsx @@ -31,6 +31,7 @@ import { } from '@backstage/test-utils'; import { CatalogKindHeader } from './CatalogKindHeader'; import { errorApiRef } from '@backstage/core-plugin-api'; +import pluralize from 'pluralize'; const entities: Entity[] = [ { @@ -96,7 +97,7 @@ describe('', () => { entities.map(entity => { expect( - screen.getByRole('option', { name: `${entity.kind}s` }), + screen.getByRole('option', { name: `${pluralize(entity.kind)}` }), ).toBeInTheDocument(); }); }); From 5ee8a146fc9700c6e06ea775c5fae127330f4ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20=C5=A0neberger?= Date: Mon, 21 Nov 2022 08:43:20 +0100 Subject: [PATCH 4/4] Better changeset message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marek Šneberger --- .changeset/thin-donuts-join.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/thin-donuts-join.md b/.changeset/thin-donuts-join.md index 10e1030801..84705711d2 100644 --- a/.changeset/thin-donuts-join.md +++ b/.changeset/thin-donuts-join.md @@ -2,4 +2,4 @@ '@backstage/plugin-catalog': patch --- -Add `pluralize()` to the catalog kind header component. +Fixed Entity kind pluralisation in the `CatalogKindHeader` component.