diff --git a/plugins/catalog-import/src/components/ImportStepper/ImportStepper.tsx b/plugins/catalog-import/src/components/ImportStepper/ImportStepper.tsx
index 791cf17965..851bab9ef7 100644
--- a/plugins/catalog-import/src/components/ImportStepper/ImportStepper.tsx
+++ b/plugins/catalog-import/src/components/ImportStepper/ImportStepper.tsx
@@ -15,13 +15,14 @@
*/
import { configApiRef, InfoCard, useApi } from '@backstage/core';
-import { Stepper } from '@material-ui/core';
+import { Step, StepContent, Stepper } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import React, { useMemo } from 'react';
import { ImportFlows, ImportState, useImportState } from '../useImportState';
import {
defaultGenerateStepper,
defaultStepper,
+ StepConfiguration,
StepperProvider,
StepperProviderOpts,
} from './defaults';
@@ -55,6 +56,15 @@ export const ImportStepper = ({
[generateStepper, state.activeFlow],
);
+ const render = (step: StepConfiguration) => {
+ return (
+
+ {step.stepLabel}
+ {step.content}
+
+ );
+ };
+
return (
- {states.analyze(
- state as Extract,
- { apis: { configApi }, opts },
+ {render(
+ states.analyze(
+ state as Extract,
+ { apis: { configApi }, opts },
+ ),
)}
- {states.prepare(
- state as Extract,
- { apis: { configApi }, opts },
+ {render(
+ states.prepare(
+ state as Extract,
+ { apis: { configApi }, opts },
+ ),
)}
- {states.review(
- state as Extract,
- { apis: { configApi }, opts },
+ {render(
+ states.review(
+ state as Extract,
+ { apis: { configApi }, opts },
+ ),
)}
- {states.finish(
- state as Extract,
- { apis: { configApi }, opts },
+ {render(
+ states.finish(
+ state as Extract,
+ { apis: { configApi }, opts },
+ ),
)}
diff --git a/plugins/catalog-import/src/components/ImportStepper/defaults.tsx b/plugins/catalog-import/src/components/ImportStepper/defaults.tsx
index 954aeb20dd..110cda9aa7 100644
--- a/plugins/catalog-import/src/components/ImportStepper/defaults.tsx
+++ b/plugins/catalog-import/src/components/ImportStepper/defaults.tsx
@@ -15,14 +15,7 @@
*/
import { ConfigApi } from '@backstage/core';
-import {
- Box,
- Step,
- StepContent,
- StepLabel,
- TextField,
- Typography,
-} from '@material-ui/core';
+import { Box, StepLabel, TextField, Typography } from '@material-ui/core';
import React from 'react';
import { BackButton } from '../Buttons';
import { StepFinishImportLocation } from '../StepFinishImportLocation';
@@ -46,23 +39,28 @@ type StepperApis = {
configApi: ConfigApi;
};
+export type StepConfiguration = {
+ stepLabel: React.ReactElement;
+ content: React.ReactElement;
+};
+
export type StepperProvider = {
analyze: (
s: Extract,
opts: { apis: StepperApis; opts?: StepperProviderOpts },
- ) => React.ReactElement;
+ ) => StepConfiguration;
prepare: (
s: Extract,
opts: { apis: StepperApis; opts?: StepperProviderOpts },
- ) => React.ReactElement;
+ ) => StepConfiguration;
review: (
s: Extract,
opts: { apis: StepperApis; opts?: StepperProviderOpts },
- ) => React.ReactElement;
+ ) => StepConfiguration;
finish: (
s: Extract,
opts: { apis: StepperApis; opts?: StepperProviderOpts },
- ) => React.ReactElement;
+ ) => StepConfiguration;
};
function defaultPreparePullRequest(apis: StepperApis) {
@@ -97,8 +95,8 @@ export function defaultGenerateStepper(
case 'single-location':
return {
...defaults,
- prepare: () => (
-
+ prepare: () => ({
+ stepLabel: (
@@ -108,8 +106,9 @@ export function defaultGenerateStepper(
>
Select Locations
-
- ),
+ ),
+ content: <>>,
+ }),
};
// let the user select one or more of the discovered locations in the prepare step
@@ -121,8 +120,8 @@ export function defaultGenerateStepper(
return defaults.prepare(state, opts);
}
- return (
-
+ return {
+ stepLabel: (
@@ -132,16 +131,16 @@ export function defaultGenerateStepper(
>
Select Locations
-
-
-
-
- );
+ ),
+ content: (
+
+ ),
+ };
},
};
@@ -158,96 +157,89 @@ export function defaultGenerateStepper(
defaultPreparePullRequest
)(opts.apis);
- return (
-
- Create Pull Request
+ return {
+ stepLabel: Create Pull Request,
+ content: (
+ (
+ <>
+
+ Pull Request Details
+
-
- (
- <>
-
-
- Pull Request Details
-
-
+
-
+
-
+
+ Entity Configuration
+
-
-
- Entity Configuration
-
-
+
-
-
-
- >
- )}
- />
-
-
- );
+
+ >
+ )}
+ />
+ ),
+ };
},
};
@@ -257,53 +249,45 @@ export function defaultGenerateStepper(
}
export const defaultStepper: StepperProvider = {
- analyze: (state, { opts }) => (
-
- Select URL
-
-
-
-
- ),
+ analyze: (state, { opts }) => ({
+ stepLabel: Select URL,
+ content: (
+
+ ),
+ }),
- prepare: state => (
-
+ prepare: state => ({
+ stepLabel: (
Optional}>
Import Actions
-
-
-
-
- ),
+ ),
+ content: ,
+ }),
- review: state => (
-
- Review
-
-
-
-
- ),
+ review: state => ({
+ stepLabel: Review,
+ content: (
+
+ ),
+ }),
- finish: state => (
-
- Finish
-
-
-
-
- ),
+ finish: state => ({
+ stepLabel: Finish,
+ content: (
+
+ ),
+ }),
};