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 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 = { 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..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'; @@ -61,18 +59,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;