From 3053e582fc4ae85f308d2680f0e5aa1953c0deba Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 2 Jan 2023 16:15:13 +0100 Subject: [PATCH] fix: workaround the typing issue by duplicating the `FormProps` type as this is the only exported type from the `/alpha` imports Signed-off-by: blam --- plugins/scaffolder/src/index.ts | 7 ++-- plugins/scaffolder/src/next/Router/Router.tsx | 2 +- .../TemplateWizardPage/TemplateWizardPage.tsx | 4 +-- plugins/scaffolder/src/next/index.ts | 1 + plugins/scaffolder/src/next/types.ts | 34 +++++++++++++++++++ 5 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 plugins/scaffolder/src/next/types.ts diff --git a/plugins/scaffolder/src/index.ts b/plugins/scaffolder/src/index.ts index c4abee4735..488ca7d670 100644 --- a/plugins/scaffolder/src/index.ts +++ b/plugins/scaffolder/src/index.ts @@ -42,5 +42,8 @@ export type { TaskPageProps } from './components/TaskPage'; /** next exports */ export { NextScaffolderPage } from './plugin'; -export type { NextRouterProps } from './next'; -export type { TemplateGroupFilter } from './next'; +export { + type TemplateGroupFilter, + type NextRouterProps, + type FormProps, +} from './next'; diff --git a/plugins/scaffolder/src/next/Router/Router.tsx b/plugins/scaffolder/src/next/Router/Router.tsx index 1c8e7ada6e..799dd10bca 100644 --- a/plugins/scaffolder/src/next/Router/Router.tsx +++ b/plugins/scaffolder/src/next/Router/Router.tsx @@ -24,13 +24,13 @@ import { FieldExtensionOptions, nextSelectedTemplateRouteRef, SecretsContextProvider, - type FormProps, } from '@backstage/plugin-scaffolder-react'; import { useElementFilter } from '@backstage/core-plugin-api'; import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common'; import { TemplateGroupFilter } from '../TemplateListPage/TemplateGroups'; import { DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS } from '../../extensions/default'; +import { FormProps } from '../types'; /** * The Props for the Scaffolder Router diff --git a/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx b/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx index d2ef72d4ae..e3717befdb 100644 --- a/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx +++ b/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx @@ -42,11 +42,11 @@ import { Stepper, NextFieldExtensionOptions, SecretsContext, - type FormProps, } from '@backstage/plugin-scaffolder-react'; import { JsonValue } from '@backstage/types'; +import { FormProps } from '../types'; -export type TemplateWizardPageProps = { +type TemplateWizardPageProps = { customFieldExtensions: NextFieldExtensionOptions[]; FormProps?: FormProps; }; diff --git a/plugins/scaffolder/src/next/index.ts b/plugins/scaffolder/src/next/index.ts index 089c268b0b..6cef3eaa03 100644 --- a/plugins/scaffolder/src/next/index.ts +++ b/plugins/scaffolder/src/next/index.ts @@ -16,3 +16,4 @@ export * from './Router'; export * from './TemplateListPage'; export * from './TemplateWizardPage'; +export * from './types'; diff --git a/plugins/scaffolder/src/next/types.ts b/plugins/scaffolder/src/next/types.ts new file mode 100644 index 0000000000..e9c77aa00e --- /dev/null +++ b/plugins/scaffolder/src/next/types.ts @@ -0,0 +1,34 @@ +/* + * 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. + */ + +/** + * These types will be replaced eventually by the one in the scaffolder-react plugin. + * It is a temporary solution to avoid the `/alpha` types being re-exported and that not being supported right now. + * It exists already in the `scaffolder-react` plugin, so you may have to update both files. + */ + +import type { FormProps as SchemaFormProps } from '@rjsf/core-v5'; + +/** + * Any `@rjsf/core` form properties that are publicly exposed to the `NextScaffolderpage` + * + * @alpha + * @deprecated use the import from {@link @backstage/plugin-scaffolder-react/alpha#FormProps} instead + */ +export type FormProps = Pick< + SchemaFormProps, + 'transformErrors' | 'noHtml5Validate' +>;