Incorporated a feedback
Signed-off-by: bnechyporenko <bnechyporenko@gmail.com> Signed-off-by: bogdannechyporenko <bogdannechiporenko@gmail.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { getReviewData } from './LastStepForm';
|
||||
import { getReviewData } from './ReviewStep';
|
||||
|
||||
describe('MultistepJsonForm', () => {
|
||||
const formDataMock = {
|
||||
|
||||
@@ -35,8 +35,8 @@ import { transformSchemaToProps } from './schema';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import * as fieldOverrides from './FieldOverrides';
|
||||
import { LayoutOptions } from '../../layouts';
|
||||
import { LastStepFormProps, Step } from '../types';
|
||||
import { LastStepForm } from './LastStepForm';
|
||||
import { ReviewStepComponentProps, Step } from '../types';
|
||||
import { ReviewStep } from './ReviewStep';
|
||||
import { selectedTemplateRouteRef } from '../../routes';
|
||||
|
||||
const Form = withTheme(MuiTheme);
|
||||
@@ -57,7 +57,7 @@ export type MultistepJsonFormProps = {
|
||||
fields?: FormProps<any>['fields'];
|
||||
finishButtonLabel?: string;
|
||||
layouts: LayoutOptions[];
|
||||
LastStepFormComponent?: ComponentType<LastStepFormProps>;
|
||||
ReviewStepComponent?: ComponentType<ReviewStepComponentProps>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ export const MultistepJsonForm = (props: MultistepJsonFormProps) => {
|
||||
widgets,
|
||||
finishButtonLabel,
|
||||
layouts,
|
||||
LastStepFormComponent,
|
||||
ReviewStepComponent,
|
||||
} = props;
|
||||
const { templateName } = useRouteRefParams(selectedTemplateRouteRef);
|
||||
const analytics = useAnalytics();
|
||||
@@ -146,7 +146,7 @@ export const MultistepJsonForm = (props: MultistepJsonFormProps) => {
|
||||
}
|
||||
};
|
||||
|
||||
const LastStepFormElement = LastStepFormComponent ?? LastStepForm;
|
||||
const ReviewStepElement = ReviewStepComponent ?? ReviewStep;
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -191,7 +191,7 @@ export const MultistepJsonForm = (props: MultistepJsonFormProps) => {
|
||||
})}
|
||||
</Stepper>
|
||||
{activeStep === steps.length && (
|
||||
<LastStepFormElement
|
||||
<ReviewStepElement
|
||||
disableButtons={disableButtons}
|
||||
handleBack={handleBack}
|
||||
handleCreate={handleCreate}
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ import React from 'react';
|
||||
import { Content, StructuredMetadataTable } from '@backstage/core-components';
|
||||
import { UiSchema } from '@rjsf/core';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { LastStepFormProps, Step } from '../types';
|
||||
import { ReviewStepComponentProps, Step } from '../types';
|
||||
|
||||
export function getUiSchemasFromSteps(steps: Step[]): UiSchema[] {
|
||||
const uiSchemas: Array<UiSchema> = [];
|
||||
@@ -77,7 +77,7 @@ export function getReviewData(formData: Record<string, any>, steps: Step[]) {
|
||||
* The component displaying the Last Step in scaffolder template form.
|
||||
* Which represents the summary of the input provided by the end user.
|
||||
*/
|
||||
export const LastStepForm = (props: LastStepFormProps) => {
|
||||
export const ReviewStep = (props: ReviewStepComponentProps) => {
|
||||
const {
|
||||
disableButtons,
|
||||
finishButtonLabel,
|
||||
@@ -46,7 +46,7 @@ import {
|
||||
} from '../routes';
|
||||
import { ListTasksPage } from './ListTasksPage';
|
||||
import { LayoutOptions, LAYOUTS_KEY, LAYOUTS_WRAPPER_KEY } from '../layouts';
|
||||
import { LastStepFormProps } from './types';
|
||||
import { ReviewStepComponentProps } from './types';
|
||||
|
||||
/**
|
||||
* The props for the entrypoint `ScaffolderPage` component the plugin.
|
||||
@@ -54,7 +54,7 @@ import { LastStepFormProps } from './types';
|
||||
*/
|
||||
export type RouterProps = {
|
||||
components?: {
|
||||
LastStepFormComponent?: ComponentType<LastStepFormProps>;
|
||||
ReviewStepComponent?: ComponentType<ReviewStepComponentProps>;
|
||||
TemplateCardComponent?:
|
||||
| ComponentType<{ template: TemplateEntityV1beta3 }>
|
||||
| undefined;
|
||||
@@ -89,7 +89,7 @@ export type RouterProps = {
|
||||
export const Router = (props: RouterProps) => {
|
||||
const { groups, components = {}, defaultPreviewTemplate } = props;
|
||||
|
||||
const { LastStepFormComponent, TemplateCardComponent, TaskPageComponent } =
|
||||
const { ReviewStepComponent, TemplateCardComponent, TaskPageComponent } =
|
||||
components;
|
||||
|
||||
const outlet = useOutlet();
|
||||
@@ -164,7 +164,7 @@ export const Router = (props: RouterProps) => {
|
||||
element={
|
||||
<SecretsContextProvider>
|
||||
<TemplatePage
|
||||
LastStepFormComponent={LastStepFormComponent}
|
||||
ReviewStepComponent={ReviewStepComponent}
|
||||
customFieldExtensions={fieldExtensions}
|
||||
layouts={customLayouts}
|
||||
/>
|
||||
|
||||
@@ -41,7 +41,7 @@ import {
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { stringifyEntityRef } from '@backstage/catalog-model';
|
||||
import { LayoutOptions } from '../../layouts';
|
||||
import { LastStepFormProps } from '../types';
|
||||
import { ReviewStepComponentProps } from '../types';
|
||||
|
||||
const useTemplateParameterSchema = (templateRef: string) => {
|
||||
const scaffolderApi = useApi(scaffolderApiRef);
|
||||
@@ -53,11 +53,11 @@ const useTemplateParameterSchema = (templateRef: string) => {
|
||||
};
|
||||
|
||||
export const TemplatePage = ({
|
||||
LastStepFormComponent,
|
||||
ReviewStepComponent,
|
||||
customFieldExtensions = [],
|
||||
layouts = [],
|
||||
}: {
|
||||
LastStepFormComponent?: ComponentType<LastStepFormProps>;
|
||||
ReviewStepComponent?: ComponentType<ReviewStepComponentProps>;
|
||||
customFieldExtensions?: FieldExtensionOptions<any, any>[];
|
||||
layouts?: LayoutOptions[];
|
||||
}) => {
|
||||
@@ -149,7 +149,7 @@ export const TemplatePage = ({
|
||||
titleTypographyProps={{ component: 'h2' }}
|
||||
>
|
||||
<MultistepJsonForm
|
||||
LastStepFormComponent={LastStepFormComponent}
|
||||
ReviewStepComponent={ReviewStepComponent}
|
||||
formData={formState}
|
||||
fields={customFieldComponents}
|
||||
onChange={handleChange}
|
||||
|
||||
@@ -19,4 +19,4 @@ export { TemplateTypePicker } from './TemplateTypePicker';
|
||||
export * from './secrets';
|
||||
export { TaskPage } from './TaskPage';
|
||||
export type { RouterProps } from './Router';
|
||||
export type { LastStepFormProps, Step } from './types';
|
||||
export type { ReviewStepComponentProps, Step } from './types';
|
||||
|
||||
@@ -33,7 +33,7 @@ export type Step = {
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type LastStepFormProps = {
|
||||
export type ReviewStepComponentProps = {
|
||||
disableButtons: boolean;
|
||||
finishButtonLabel?: string;
|
||||
formData: Record<string, any>;
|
||||
|
||||
Reference in New Issue
Block a user