From 9b1fadf6d8a3e45eeec137f35d9a63adc7910b14 Mon Sep 17 00:00:00 2001 From: Paul Cowan Date: Fri, 16 Dec 2022 14:14:20 +0000 Subject: [PATCH 1/5] configurable noHtml5Validate prop for NextScaffolderPage Signed-off-by: Paul Cowan --- .changeset/eighty-pans-remain.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/eighty-pans-remain.md diff --git a/.changeset/eighty-pans-remain.md b/.changeset/eighty-pans-remain.md new file mode 100644 index 0000000000..a93b0cc8c7 --- /dev/null +++ b/.changeset/eighty-pans-remain.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder': patch +--- + +configurable noHtml5Validate prop for NextScaffolderPage From 90b677a967db7a7df3087b1268b132ec736e6688 Mon Sep 17 00:00:00 2001 From: Paul Cowan Date: Sat, 17 Dec 2022 11:13:12 +0000 Subject: [PATCH 2/5] add noHtml5Validate prop check to NextScaffolder page test Signed-off-by: Paul Cowan --- plugins/scaffolder/src/next/Router/Router.test.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/scaffolder/src/next/Router/Router.test.tsx b/plugins/scaffolder/src/next/Router/Router.test.tsx index 0e890005ac..fb2072c1a0 100644 --- a/plugins/scaffolder/src/next/Router/Router.test.tsx +++ b/plugins/scaffolder/src/next/Router/Router.test.tsx @@ -54,11 +54,11 @@ describe('Router', () => { expect(TemplateWizardPage).toHaveBeenCalled(); }); - it('should pass through the transformErrors property', async () => { + it('should pass through the FormProps property', async () => { const transformErrorsMock = jest.fn(); await renderInTestApp( - , + , { routeEntries: ['/templates/default/foo'], }, @@ -68,13 +68,14 @@ describe('Router', () => { const [ { - FormProps: { transformErrors }, + FormProps, }, ] = mock.mock.calls[0]; - expect(transformErrors).toEqual(transformErrors); + expect(FormProps).toEqual({transformErrors: transformErrorsMock, noHtml5Validate: true}); }); + it('should extract the fieldExtensions and pass them through', async () => { const mockComponent = () => null; const CustomFieldExtension = scaffolderPlugin.provide( From 0f797c07f1717ba445da44724f9270cffe7d58be Mon Sep 17 00:00:00 2001 From: Paul Cowan Date: Tue, 20 Dec 2022 10:23:38 +0000 Subject: [PATCH 3/5] fix next/router tests to use FormProps Signed-off-by: Paul Cowan --- plugins/scaffolder/api-report.md | 5 ++++- plugins/scaffolder/src/next/types.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/scaffolder/api-report.md b/plugins/scaffolder/api-report.md index 7611e952dc..3fe1208ba9 100644 --- a/plugins/scaffolder/api-report.md +++ b/plugins/scaffolder/api-report.md @@ -168,7 +168,10 @@ export interface FieldSchema { } // @alpha -export type FormProps = Pick; +export type FormProps = Pick< + FormProps_3, + 'transformErrors' | 'noHtml5Validate' +>; // @public export type LayoutComponent<_TInputProps> = () => null; diff --git a/plugins/scaffolder/src/next/types.ts b/plugins/scaffolder/src/next/types.ts index d0d3ed1011..32d0fe85f0 100644 --- a/plugins/scaffolder/src/next/types.ts +++ b/plugins/scaffolder/src/next/types.ts @@ -20,4 +20,7 @@ import type { FormProps as SchemaFormProps } from '@rjsf/core-v5'; * * @alpha */ -export type FormProps = Pick; +export type FormProps = Pick< + SchemaFormProps, + 'transformErrors' | 'noHtml5Validate' +>; From 0f2cd3dfe9e34d6f297ed7361e1a560ec75695fe Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 20 Dec 2022 10:29:34 +0000 Subject: [PATCH 4/5] Update .changeset/eighty-pans-remain.md Co-authored-by: Ben Lambert Signed-off-by: Paul Signed-off-by: Paul Cowan --- .changeset/eighty-pans-remain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/eighty-pans-remain.md b/.changeset/eighty-pans-remain.md index a93b0cc8c7..963280e5a5 100644 --- a/.changeset/eighty-pans-remain.md +++ b/.changeset/eighty-pans-remain.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder': patch --- -configurable noHtml5Validate prop for NextScaffolderPage +Added `noHtml5Validate` prop to `FormProps` on `NextScaffolderPage` From 8c718daefa63e4993c7142511ddcbccdd33acd7b Mon Sep 17 00:00:00 2001 From: Paul Cowan Date: Tue, 20 Dec 2022 10:59:44 +0000 Subject: [PATCH 5/5] run prettier Signed-off-by: Paul Cowan --- .../src/next/Router/Router.test.tsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugins/scaffolder/src/next/Router/Router.test.tsx b/plugins/scaffolder/src/next/Router/Router.test.tsx index fb2072c1a0..89f8f6ecd3 100644 --- a/plugins/scaffolder/src/next/Router/Router.test.tsx +++ b/plugins/scaffolder/src/next/Router/Router.test.tsx @@ -58,7 +58,12 @@ describe('Router', () => { const transformErrorsMock = jest.fn(); await renderInTestApp( - , + , { routeEntries: ['/templates/default/foo'], }, @@ -66,16 +71,14 @@ describe('Router', () => { const mock = TemplateWizardPage as jest.Mock; - const [ - { - FormProps, - }, - ] = mock.mock.calls[0]; + const [{ FormProps }] = mock.mock.calls[0]; - expect(FormProps).toEqual({transformErrors: transformErrorsMock, noHtml5Validate: true}); + expect(FormProps).toEqual({ + transformErrors: transformErrorsMock, + noHtml5Validate: true, + }); }); - it('should extract the fieldExtensions and pass them through', async () => { const mockComponent = () => null; const CustomFieldExtension = scaffolderPlugin.provide(