diff --git a/plugins/scaffolder/api-report.md b/plugins/scaffolder/api-report.md index db928f0c62..808decc89e 100644 --- a/plugins/scaffolder/api-report.md +++ b/plugins/scaffolder/api-report.md @@ -11,7 +11,6 @@ import { BackstagePlugin } from '@backstage/core-plugin-api'; import { ComponentType } from 'react'; import { DiscoveryApi } from '@backstage/core-plugin-api'; import { Entity } from '@backstage/catalog-model'; -import type { ErrorTransformer } from '@rjsf/utils'; import { Extension } from '@backstage/core-plugin-api'; import { ExternalRouteRef } from '@backstage/core-plugin-api'; import { FetchApi } from '@backstage/core-plugin-api'; @@ -19,7 +18,8 @@ import { FieldProps } from '@rjsf/core'; import { FieldProps as FieldProps_2 } from '@rjsf/utils'; import { FieldValidation } from '@rjsf/core'; import { FieldValidation as FieldValidation_2 } from '@rjsf/utils'; -import type { FormProps } from '@rjsf/core'; +import type { FormProps as FormProps_2 } from '@rjsf/core'; +import type { FormProps as FormProps_3 } from '@rjsf/core-v5'; import { IdentityApi } from '@backstage/core-plugin-api'; import { JsonObject } from '@backstage/types'; import { JSONSchema7 } from 'json-schema'; @@ -167,6 +167,9 @@ export interface FieldSchema { readonly uiOptionsType: TUiOptions; } +// @alpha +export type FormProps = Pick; + // @public export type LayoutComponent<_TInputProps> = () => null; @@ -179,7 +182,7 @@ export interface LayoutOptions

{ } // @public -export type LayoutTemplate = FormProps['ObjectFieldTemplate']; +export type LayoutTemplate = FormProps_2['ObjectFieldTemplate']; // @public export type ListActionsResponse = Array<{ @@ -264,8 +267,7 @@ export type NextRouterProps = { TaskPageComponent?: React_2.ComponentType<{}>; }; groups?: TemplateGroupFilter[]; - transformErrors?: ErrorTransformer; -}; +} & FormProps; // @alpha export const NextScaffolderPage: ( diff --git a/plugins/scaffolder/src/index.ts b/plugins/scaffolder/src/index.ts index 0e5e2630ac..1ed1346176 100644 --- a/plugins/scaffolder/src/index.ts +++ b/plugins/scaffolder/src/index.ts @@ -74,6 +74,7 @@ export type { TaskPageProps } from './components/TaskPage'; export { NextScaffolderPage } from './plugin'; export type { NextRouterProps } from './next'; export type { TemplateGroupFilter } from './next'; +export type { FormProps } from './next'; export { createNextScaffolderFieldExtension, type NextCustomFieldValidator, diff --git a/plugins/scaffolder/src/next/Router/Router.tsx b/plugins/scaffolder/src/next/Router/Router.tsx index ecf89c8742..9ce1ad9588 100644 --- a/plugins/scaffolder/src/next/Router/Router.tsx +++ b/plugins/scaffolder/src/next/Router/Router.tsx @@ -30,7 +30,7 @@ import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common'; import { TemplateGroupFilter } from '../TemplateListPage/TemplateGroups'; import { nextSelectedTemplateRouteRef } from '../../routes'; import { SecretsContextProvider } from '../../components/secrets/SecretsContext'; -import type { ErrorTransformer } from '@rjsf/utils'; +import type { FormProps } from '../types'; /** * The Props for the Scaffolder Router @@ -45,8 +45,7 @@ export type NextRouterProps = { TaskPageComponent?: React.ComponentType<{}>; }; groups?: TemplateGroupFilter[]; - transformErrors?: ErrorTransformer; -}; +} & FormProps; /** * The Scaffolder Router diff --git a/plugins/scaffolder/src/next/TemplateWizardPage/Stepper/Stepper.tsx b/plugins/scaffolder/src/next/TemplateWizardPage/Stepper/Stepper.tsx index fffacae2f2..c11fd450ee 100644 --- a/plugins/scaffolder/src/next/TemplateWizardPage/Stepper/Stepper.tsx +++ b/plugins/scaffolder/src/next/TemplateWizardPage/Stepper/Stepper.tsx @@ -36,9 +36,9 @@ import { useTemplateSchema } from './useTemplateSchema'; import { ReviewState } from './ReviewState'; import validator from '@rjsf/validator-ajv8'; import { selectedTemplateRouteRef } from '../../../routes'; -import type { ErrorTransformer } from '@rjsf/utils'; import { getDefaultFormState } from '@rjsf/utils'; import { useFormData } from './useFormData'; +import { FormProps } from '../../types'; const useStyles = makeStyles(theme => ({ backButton: { @@ -55,12 +55,11 @@ const useStyles = makeStyles(theme => ({ }, })); -export interface StepperProps { +export type StepperProps = { manifest: TemplateParameterSchema; extensions: NextFieldExtensionOptions[]; onComplete: (values: Record) => Promise; - transformErrors?: ErrorTransformer; -} +} & FormProps; // TODO(blam): We require here, as the types in this package depend on @rjsf/core explicitly // which is what we're using here as the default types, it needs to depend on @rjsf/core-v5 because diff --git a/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx b/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx index 31a5808233..0990bb40ce 100644 --- a/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx +++ b/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx @@ -44,12 +44,11 @@ import { } from '../../routes'; import { SecretsContext } from '../../components/secrets/SecretsContext'; import { JsonValue } from '@backstage/types'; -import type { ErrorTransformer } from '@rjsf/utils'; +import type { FormProps } from '../types'; -export interface TemplateWizardPageProps { +export type TemplateWizardPageProps = { customFieldExtensions: NextFieldExtensionOptions[]; - transformErrors?: ErrorTransformer; -} +} & FormProps; const useStyles = makeStyles(() => ({ markdown: { diff --git a/plugins/scaffolder/src/next/index.ts b/plugins/scaffolder/src/next/index.ts index 089c268b0b..3a874e3b41 100644 --- a/plugins/scaffolder/src/next/index.ts +++ b/plugins/scaffolder/src/next/index.ts @@ -16,3 +16,5 @@ export * from './Router'; export * from './TemplateListPage'; export * from './TemplateWizardPage'; + +export type { FormProps } from './types'; diff --git a/plugins/scaffolder/src/next/types.ts b/plugins/scaffolder/src/next/types.ts new file mode 100644 index 0000000000..d0d3ed1011 --- /dev/null +++ b/plugins/scaffolder/src/next/types.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2022 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import type { FormProps as SchemaFormProps } from '@rjsf/core-v5'; + +/** + * Any `@rjsf/core` form properties that are publicly exposed to the `NextScaffolderpage` + * + * @alpha + */ +export type FormProps = Pick;