catalog-import: Display prepareResult in final step

Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2021-06-07 13:21:52 +02:00
parent 18ddc1b318
commit 70bc30c5b7
6 changed files with 19 additions and 19 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/catalog-client': patch
'@backstage/plugin-catalog-import': patch
---
Display preview result final step.
@@ -134,12 +134,6 @@ export class CatalogClient implements CatalogApi {
throw new Error(`Location wasn't added: ${target}`);
}
// TODO(jhaals): This will throw using the experimental catalog since all discovered entities are deferred.
if (entities.length === 0) {
throw new Error(
`Location was added but has no entities specified yet: ${target}`,
);
}
return {
location,
entities,
@@ -328,7 +328,7 @@ export const defaultStepper: StepperProvider = {
stepLabel: <StepLabel>Finish</StepLabel>,
content: (
<StepFinishImportLocation
reviewResult={state.reviewResult}
prepareResult={state.prepareResult}
onReset={state.onReset}
/>
),
@@ -20,25 +20,25 @@ import LocationOnIcon from '@material-ui/icons/LocationOn';
import React from 'react';
import { BackButton } from '../Buttons';
import { EntityListComponent } from '../EntityListComponent';
import { ReviewResult } from '../useImportState';
import { PrepareResult } from '../useImportState';
type Props = {
reviewResult: ReviewResult;
prepareResult: PrepareResult;
onReset: () => void;
};
export const StepFinishImportLocation = ({ reviewResult, onReset }: Props) => (
export const StepFinishImportLocation = ({ prepareResult, onReset }: Props) => (
<>
{reviewResult.type === 'repository' && (
{prepareResult.type === 'repository' && (
<>
<Typography paragraph>
The following Pull Request has been opened:{' '}
<Link
to={reviewResult.pullRequest.url}
to={prepareResult.pullRequest.url}
target="_blank"
rel="noreferrer"
>
{reviewResult.pullRequest.url}
{prepareResult.pullRequest.url}
</Link>
</Typography>
@@ -53,7 +53,7 @@ export const StepFinishImportLocation = ({ reviewResult, onReset }: Props) => (
</Typography>
<EntityListComponent
locations={reviewResult.locations}
locations={prepareResult.locations}
locationListItemIcon={() => <LocationOnIcon />}
withLinks
/>
@@ -127,7 +127,7 @@ describe('useImportState', () => {
activeState: 'finish',
analyzeResult: locationAP,
prepareResult: locationAP,
reviewResult: locationR,
reviewResult: locationAP,
});
act(() => result.current.onReset());
@@ -138,8 +138,8 @@ describe('useImportState', () => {
analysisUrl: undefined,
activeState: 'analyze',
analyzeResult: undefined,
prepareResult: undefined,
reviewResult: locationR,
prepareResult: locationR,
reviewResult: undefined,
});
});
@@ -227,9 +227,9 @@ function reducer(state: ReducerState, action: ReducerActions): ReducerState {
return {
...init(action.initialUrl),
// we keep the old reviewResult since the form is animated and an
// we keep the old prepareResult since the form is animated and an
// undefined value might crash the last step.
reviewResult: state.reviewResult,
prepareResult: state.prepareResult,
};
default: