From 1b1a04de06a8fce40b5f965549b8320d591a78d8 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 24 May 2023 14:29:59 +0200 Subject: [PATCH 1/4] feat: use the old way of filtering Signed-off-by: blam --- .../TemplateGroup/TemplateGroup.test.tsx | 30 +++++++------------ .../TemplateGroup/TemplateGroup.tsx | 13 +------- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/plugins/scaffolder-react/src/next/components/TemplateGroup/TemplateGroup.test.tsx b/plugins/scaffolder-react/src/next/components/TemplateGroup/TemplateGroup.test.tsx index 02756839c9..8d8ae718dc 100644 --- a/plugins/scaffolder-react/src/next/components/TemplateGroup/TemplateGroup.test.tsx +++ b/plugins/scaffolder-react/src/next/components/TemplateGroup/TemplateGroup.test.tsx @@ -22,16 +22,6 @@ import { TemplateCard } from '../TemplateCard'; import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common'; describe('TemplateGroup', () => { - it('should return a message when no templates are passed in', async () => { - const { getByText } = render( - , - ); - - expect( - getByText(/No templates found that match your filter/), - ).toBeInTheDocument(); - }); - it('should render a card for each template with the template being passed as a prop', () => { const mockOnSelected = jest.fn(); const mockTemplates: { template: TemplateEntityV1beta3 }[] = [ @@ -130,14 +120,6 @@ describe('TemplateGroup', () => { ); } }); - - it('should render the title when no templates passed', () => { - const { getByText } = render( - , - ); - expect(getByText('Test')).toBeInTheDocument(); - }); - it('should render the title when there are templates in the list', () => { const mockTemplates: { template: TemplateEntityV1beta3 }[] = [ { @@ -163,10 +145,20 @@ describe('TemplateGroup', () => { it('should allow for passing through a user given title component', () => { const TitleComponent =

Im a custom header

; + const mockTemplates: { template: TemplateEntityV1beta3 }[] = [ + { + template: { + apiVersion: 'scaffolder.backstage.io/v1beta3', + kind: 'Template', + metadata: { name: 'test' }, + spec: { parameters: [], steps: [], type: 'website' }, + }, + }, + ]; const { getByText } = render( , ); diff --git a/plugins/scaffolder-react/src/next/components/TemplateGroup/TemplateGroup.tsx b/plugins/scaffolder-react/src/next/components/TemplateGroup/TemplateGroup.tsx index 8134ea256d..03f866922b 100644 --- a/plugins/scaffolder-react/src/next/components/TemplateGroup/TemplateGroup.tsx +++ b/plugins/scaffolder-react/src/next/components/TemplateGroup/TemplateGroup.tsx @@ -61,18 +61,7 @@ export const TemplateGroup = (props: TemplateGroupProps) => { typeof title === 'string' ? : title; if (templates.length === 0) { - return ( - - {titleComponent} - - No templates found that match your filter. Learn more about{' '} - - adding templates - - . - - - ); + return null; } const Card = CardComponent || TemplateCard; From 4505dc3b45989232591cac967bc8abc1a6201a74 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 24 May 2023 14:32:15 +0200 Subject: [PATCH 2/4] chore: changeset Signed-off-by: blam --- .changeset/shy-numbers-try.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/shy-numbers-try.md diff --git a/.changeset/shy-numbers-try.md b/.changeset/shy-numbers-try.md new file mode 100644 index 0000000000..a0af1bf12b --- /dev/null +++ b/.changeset/shy-numbers-try.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-react': minor +--- + +`scaffolder/next`: Don't render `TemplateGroups` when there's no results in with search query From ed5d7c2ecb6f4e2a00fa49acdbe64d5eff63c141 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 24 May 2023 14:33:59 +0200 Subject: [PATCH 3/4] lint: fix Signed-off-by: blam --- .../src/next/components/TemplateGroup/TemplateGroup.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/scaffolder-react/src/next/components/TemplateGroup/TemplateGroup.tsx b/plugins/scaffolder-react/src/next/components/TemplateGroup/TemplateGroup.tsx index 03f866922b..215ec2827e 100644 --- a/plugins/scaffolder-react/src/next/components/TemplateGroup/TemplateGroup.tsx +++ b/plugins/scaffolder-react/src/next/components/TemplateGroup/TemplateGroup.tsx @@ -19,9 +19,7 @@ import { Content, ContentHeader, ItemCardGrid, - Link, } from '@backstage/core-components'; -import { Typography } from '@material-ui/core'; import { stringifyEntityRef } from '@backstage/catalog-model'; import { TemplateCardProps, TemplateCard } from '../TemplateCard'; import { IconComponent } from '@backstage/core-plugin-api'; From 032b4fc8517eeee9c11a5491af61b85b0fd1aa20 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 24 May 2023 15:55:30 +0200 Subject: [PATCH 4/4] chore: TemplateGroup can render empty now Signed-off-by: blam --- plugins/scaffolder-react/alpha-api-report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scaffolder-react/alpha-api-report.md b/plugins/scaffolder-react/alpha-api-report.md index 319e3963f0..6c22a5caa9 100644 --- a/plugins/scaffolder-react/alpha-api-report.md +++ b/plugins/scaffolder-react/alpha-api-report.md @@ -206,7 +206,7 @@ export interface TemplateCardProps { export const TemplateCategoryPicker: () => JSX.Element | null; // @alpha -export const TemplateGroup: (props: TemplateGroupProps) => JSX.Element; +export const TemplateGroup: (props: TemplateGroupProps) => JSX.Element | null; // @alpha (undocumented) export type TemplateGroupFilter = {