From 2986f8e09d4d16bf6ddef0678afc3ca93c91c0bb Mon Sep 17 00:00:00 2001 From: Diego Bardari Date: Thu, 3 Mar 2022 10:38:31 +0100 Subject: [PATCH] Fixed EntityOwnerPicker and OwnershipCard url filter issue Signed-off-by: Diego Bardari --- .changeset/strong-beds-attack.md | 6 ++++++ .../catalog-react/src/hooks/useEntityListProvider.tsx | 2 +- .../Cards/OwnershipCard/OwnershipCard.test.tsx | 4 ++-- .../components/Cards/OwnershipCard/OwnershipCard.tsx | 11 ++++++++--- 4 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 .changeset/strong-beds-attack.md diff --git a/.changeset/strong-beds-attack.md b/.changeset/strong-beds-attack.md new file mode 100644 index 0000000000..f16c709daa --- /dev/null +++ b/.changeset/strong-beds-attack.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-catalog-react': patch +'@backstage/plugin-org': patch +--- + +Fixed EntityOwnerPicker and OwnershipCard url filter issue with more than 21 owners diff --git a/plugins/catalog-react/src/hooks/useEntityListProvider.tsx b/plugins/catalog-react/src/hooks/useEntityListProvider.tsx index f448e41b82..72dfb7d1c3 100644 --- a/plugins/catalog-react/src/hooks/useEntityListProvider.tsx +++ b/plugins/catalog-react/src/hooks/useEntityListProvider.tsx @@ -195,7 +195,7 @@ export const EntityListProvider = ({ }); const newParams = qs.stringify( { ...oldParams, filters: queryParams }, - { addQueryPrefix: true }, + { addQueryPrefix: true, arrayFormat: 'repeat' }, ); const newUrl = `${window.location.pathname}${newParams}`; // We use direct history manipulation since useSearchParams and diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx index 3fc770e6b5..f6aaef6344 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx @@ -248,7 +248,7 @@ describe('OwnershipCard', () => { expect(getByText('OPENAPI').closest('a')).toHaveAttribute( 'href', - '/create/?filters%5Bkind%5D=API&filters%5Btype%5D=openapi&filters%5Bowners%5D%5B0%5D=my-team&filters%5Buser%5D=all', + '/create/?filters%5Bkind%5D=API&filters%5Btype%5D=openapi&filters%5Bowners%5D=my-team&filters%5Buser%5D=all', ); }); @@ -295,7 +295,7 @@ describe('OwnershipCard', () => { expect(getByText('OPENAPI').closest('a')).toHaveAttribute( 'href', - '/create/?filters%5Bkind%5D=API&filters%5Btype%5D=openapi&filters%5Bowners%5D%5B0%5D=user%3Athe-user&filters%5Bowners%5D%5B1%5D=my-team&filters%5Buser%5D=all', + '/create/?filters%5Bkind%5D=API&filters%5Btype%5D=openapi&filters%5Bowners%5D=user%3Athe-user&filters%5Bowners%5D=my-team&filters%5Buser%5D=all', ); }); }); diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx index 2b292cbe8b..1553bcac97 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx @@ -120,9 +120,14 @@ const getQueryParams = ( const user = owner as UserEntity; filters.owners = [...filters.owners, ...user.spec.memberOf]; } - const queryParams = qs.stringify({ - filters, - }); + const queryParams = qs.stringify( + { + filters, + }, + { + arrayFormat: 'repeat', + }, + ); return queryParams; };