From 6965ead7800974c3136b2f38995ae50ac99bda46 Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Fri, 14 Oct 2022 09:09:24 +0200 Subject: [PATCH] Make last step (a summary page of scaffolder template) configurable. Signed-off-by: bnechyporenko --- .../MultistepJsonForm/LastStepForm.tsx | 17 +++++++++++++++++ .../MultistepJsonForm/MultistepJsonForm.tsx | 5 +++++ .../src/components/MultistepJsonForm/index.ts | 1 + .../src/components/MultistepJsonForm/types.ts | 5 +++++ plugins/scaffolder/src/components/index.ts | 1 + plugins/scaffolder/src/index.ts | 4 ++++ plugins/scaffolder/src/options.ts | 13 +++++++++++-- plugins/scaffolder/src/plugin.tsx | 2 +- 8 files changed, 45 insertions(+), 3 deletions(-) diff --git a/plugins/scaffolder/src/components/MultistepJsonForm/LastStepForm.tsx b/plugins/scaffolder/src/components/MultistepJsonForm/LastStepForm.tsx index ff5f27ff60..3ee6609c73 100644 --- a/plugins/scaffolder/src/components/MultistepJsonForm/LastStepForm.tsx +++ b/plugins/scaffolder/src/components/MultistepJsonForm/LastStepForm.tsx @@ -20,6 +20,12 @@ import { Step } from './types'; import { UiSchema } from '@rjsf/core'; import { JsonObject } from '@backstage/types'; +/** + * The props for the Last Step in scaffolder template form. + * Which represents the summary of the input provided by the end user. + * + * @public + */ export type LastStepFormProps = { disableButtons: boolean; finishButtonLabel?: string; @@ -84,6 +90,12 @@ export function getReviewData(formData: Record, steps: Step[]) { return reviewData; } +/** + * The component displaying the Last Step in scaffolder template form. + * Which represents the summary of the input provided by the end user. + * + * @public + */ export const LastStepForm = (props: LastStepFormProps) => { const { disableButtons, @@ -123,6 +135,11 @@ export const LastStepForm = (props: LastStepFormProps) => { ); }; +/** + * Creates LastStepForm from provided properties. + * + * @public + */ export const lastStepFormComponent = (props: LastStepFormProps) => ( ); diff --git a/plugins/scaffolder/src/components/MultistepJsonForm/MultistepJsonForm.tsx b/plugins/scaffolder/src/components/MultistepJsonForm/MultistepJsonForm.tsx index acb4ce8429..4f067141c9 100644 --- a/plugins/scaffolder/src/components/MultistepJsonForm/MultistepJsonForm.tsx +++ b/plugins/scaffolder/src/components/MultistepJsonForm/MultistepJsonForm.tsx @@ -53,6 +53,11 @@ type Props = { layouts: LayoutOptions[]; }; +/** + * Creates the dynamic form for a scaffolder template. + * + * @public + */ export const MultistepJsonForm = (props: Props) => { const { formData, diff --git a/plugins/scaffolder/src/components/MultistepJsonForm/index.ts b/plugins/scaffolder/src/components/MultistepJsonForm/index.ts index d78d7376ba..59c58fcb05 100644 --- a/plugins/scaffolder/src/components/MultistepJsonForm/index.ts +++ b/plugins/scaffolder/src/components/MultistepJsonForm/index.ts @@ -16,3 +16,4 @@ export { MultistepJsonForm } from './MultistepJsonForm'; export { lastStepFormComponent, LastStepForm } from './LastStepForm'; export type { LastStepFormProps } from './LastStepForm'; +export type { Step } from './types'; diff --git a/plugins/scaffolder/src/components/MultistepJsonForm/types.ts b/plugins/scaffolder/src/components/MultistepJsonForm/types.ts index 864698e1a9..8be77bbfe5 100644 --- a/plugins/scaffolder/src/components/MultistepJsonForm/types.ts +++ b/plugins/scaffolder/src/components/MultistepJsonForm/types.ts @@ -16,6 +16,11 @@ import { FormProps } from '@rjsf/core'; import { JsonObject } from '@backstage/types'; +/** + * The props for the Step in scaffolder template. + * + * @public + */ export type Step = { schema: JsonObject; title: string; diff --git a/plugins/scaffolder/src/components/index.ts b/plugins/scaffolder/src/components/index.ts index d0442cb906..20bdcf2ad3 100644 --- a/plugins/scaffolder/src/components/index.ts +++ b/plugins/scaffolder/src/components/index.ts @@ -19,3 +19,4 @@ export { TemplateTypePicker } from './TemplateTypePicker'; export * from './secrets'; export { TaskPage } from './TaskPage'; export type { RouterProps } from './Router'; +export * from './MultistepJsonForm'; diff --git a/plugins/scaffolder/src/index.ts b/plugins/scaffolder/src/index.ts index e68eece8e5..12aa8e28ec 100644 --- a/plugins/scaffolder/src/index.ts +++ b/plugins/scaffolder/src/index.ts @@ -67,6 +67,10 @@ export type { TaskPageProps } from './components/TaskPage'; export { NextScaffolderPage } from './plugin'; export type { NextRouterProps } from './next'; export type { TemplateGroupFilter } from './next'; +export type { + ScaffolderInputPluginOptionsOptions, + ScaffolderPluginOptions, +} from './options'; export { createNextScaffolderFieldExtension, type NextCustomFieldValidator, diff --git a/plugins/scaffolder/src/options.ts b/plugins/scaffolder/src/options.ts index 430274470c..90cdd9ba2a 100644 --- a/plugins/scaffolder/src/options.ts +++ b/plugins/scaffolder/src/options.ts @@ -16,13 +16,22 @@ import { usePluginOptions } from '@backstage/core-plugin-api'; import { ReactElement } from 'react'; -import { LastStepFormProps } from './components/MultistepJsonForm'; +import { LastStepFormProps } from './components'; +/** + * Scaffolder Plugin options to override default plugin behavior. + * + * @public + */ export type ScaffolderPluginOptions = { lastStepFormComponent: (props: LastStepFormProps) => ReactElement; }; -/** @ignore */ +/** + * Scaffolder Plugin options to override default plugin behavior. + * + * @public + */ export type ScaffolderInputPluginOptionsOptions = { lastStepFormComponent: (props: LastStepFormProps) => ReactElement; }; diff --git a/plugins/scaffolder/src/plugin.tsx b/plugins/scaffolder/src/plugin.tsx index c439faecd5..324bd1bf28 100644 --- a/plugins/scaffolder/src/plugin.tsx +++ b/plugins/scaffolder/src/plugin.tsx @@ -43,7 +43,7 @@ import { ScaffolderInputPluginOptionsOptions, ScaffolderPluginOptions, } from './options'; -import { lastStepFormComponent } from './components/MultistepJsonForm'; +import { lastStepFormComponent } from './components'; /** * The main plugin export for the scaffolder.