remove layouts from Stepper
Signed-off-by: Paul Cowan <paul.cowan@cutting.scot>
This commit is contained in:
@@ -154,7 +154,6 @@ export const MultistepJsonForm = (props: Props) => {
|
||||
)
|
||||
: filteredStep.schema.required;
|
||||
}
|
||||
|
||||
return filteredStep;
|
||||
};
|
||||
|
||||
|
||||
@@ -22,13 +22,7 @@ import {
|
||||
createScaffolderFieldExtension,
|
||||
ScaffolderFieldExtensions,
|
||||
} from '../../extensions';
|
||||
import {
|
||||
createScaffolderLayout,
|
||||
DEFAULT_SCAFFOLDER_LAYOUT,
|
||||
ScaffolderLayouts,
|
||||
} from '../../layouts';
|
||||
import { scaffolderPlugin } from '../../plugin';
|
||||
import { ObjectFieldTemplateProps } from '@rjsf/core';
|
||||
|
||||
jest.mock('../TemplateListPage', () => ({
|
||||
TemplateListPage: jest.fn(() => null),
|
||||
@@ -87,42 +81,5 @@ describe('Router', () => {
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it('should use the default layout', async () => {
|
||||
await renderInTestApp(<Router />, {
|
||||
routeEntries: ['/templates/default/foo'],
|
||||
});
|
||||
|
||||
const mock = TemplateWizardPage as jest.Mock;
|
||||
|
||||
const [{ layout }] = mock.mock.calls[0];
|
||||
|
||||
expect(layout).toEqual(DEFAULT_SCAFFOLDER_LAYOUT);
|
||||
});
|
||||
|
||||
it('should extract the custom layout and pass it through', async () => {
|
||||
const mockLayout = () => null;
|
||||
const Customlayout = scaffolderPlugin.provide(
|
||||
createScaffolderLayout({
|
||||
name: 'CustomLayout',
|
||||
component: mockLayout,
|
||||
}),
|
||||
);
|
||||
|
||||
await renderInTestApp(
|
||||
<Router>
|
||||
<ScaffolderLayouts>
|
||||
<Customlayout />
|
||||
</ScaffolderLayouts>
|
||||
</Router>,
|
||||
{ routeEntries: ['/templates/default/foo'] },
|
||||
);
|
||||
|
||||
const mock = TemplateWizardPage as jest.Mock;
|
||||
// eslint-disable-next-line no-console
|
||||
const [{ layout }] = mock.mock.calls[0];
|
||||
|
||||
expect(layout).toEqual({ name: 'CustomLayout', component: mockLayout });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -29,12 +29,6 @@ import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';
|
||||
import { TemplateGroupFilter } from '../TemplateListPage/TemplateGroups';
|
||||
import { nextSelectedTemplateRouteRef } from '../../routes';
|
||||
import { SecretsContextProvider } from '../../components/secrets/SecretsContext';
|
||||
import {
|
||||
DEFAULT_SCAFFOLDER_LAYOUT,
|
||||
LayoutOptions,
|
||||
LAYOUTS_KEY,
|
||||
LAYOUTS_WRAPPER_KEY,
|
||||
} from '../../layouts';
|
||||
|
||||
/**
|
||||
* The Props for the Scaffolder Router
|
||||
@@ -81,24 +75,6 @@ export const Router = (props: PropsWithChildren<NextRouterProps>) => {
|
||||
),
|
||||
];
|
||||
|
||||
const customLayouts = useElementFilter(outlet, elements =>
|
||||
elements
|
||||
.selectByComponentData({
|
||||
key: LAYOUTS_WRAPPER_KEY,
|
||||
})
|
||||
.findComponentData<LayoutOptions>({
|
||||
key: LAYOUTS_KEY,
|
||||
}),
|
||||
);
|
||||
|
||||
if (
|
||||
!customLayouts.find(
|
||||
layout => layout.name === DEFAULT_SCAFFOLDER_LAYOUT.name,
|
||||
)
|
||||
) {
|
||||
customLayouts.push(DEFAULT_SCAFFOLDER_LAYOUT);
|
||||
}
|
||||
|
||||
return (
|
||||
<Routes>
|
||||
<Route
|
||||
@@ -115,10 +91,7 @@ export const Router = (props: PropsWithChildren<NextRouterProps>) => {
|
||||
path={nextSelectedTemplateRouteRef.path}
|
||||
element={
|
||||
<SecretsContextProvider>
|
||||
<TemplateWizardPage
|
||||
customFieldExtensions={fieldExtensions}
|
||||
layouts={customLayouts}
|
||||
/>
|
||||
<TemplateWizardPage customFieldExtensions={fieldExtensions} />
|
||||
</SecretsContextProvider>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -18,7 +18,6 @@ import { TemplateParameterSchema } from '../../../types';
|
||||
import { Stepper } from './Stepper';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { act, fireEvent } from '@testing-library/react';
|
||||
import { DEFAULT_SCAFFOLDER_LAYOUT } from '../../../layouts';
|
||||
|
||||
describe('Stepper', () => {
|
||||
it('should render the step titles for each step of the manifest', async () => {
|
||||
@@ -31,11 +30,7 @@ describe('Stepper', () => {
|
||||
};
|
||||
|
||||
const { getByText } = await renderInTestApp(
|
||||
<Stepper
|
||||
manifest={manifest}
|
||||
extensions={[]}
|
||||
layout={DEFAULT_SCAFFOLDER_LAYOUT}
|
||||
/>,
|
||||
<Stepper manifest={manifest} extensions={[]} />,
|
||||
);
|
||||
|
||||
for (const step of manifest.steps) {
|
||||
@@ -139,7 +134,6 @@ describe('Stepper', () => {
|
||||
<Stepper
|
||||
manifest={manifest}
|
||||
extensions={[{ name: 'Mock', component: MockComponent }]}
|
||||
layout={DEFAULT_SCAFFOLDER_LAYOUT}
|
||||
/>,
|
||||
);
|
||||
|
||||
|
||||
@@ -37,11 +37,9 @@ import { makeStyles } from '@material-ui/core';
|
||||
import { Stepper } from './Stepper';
|
||||
import { BackstageTheme } from '@backstage/theme';
|
||||
import { nextRouteRef, selectedTemplateRouteRef } from '../../routes';
|
||||
import type { LayoutOptions } from '../../layouts';
|
||||
|
||||
export interface TemplateWizardPageProps {
|
||||
customFieldExtensions: FieldExtensionOptions<any, any>[];
|
||||
layouts: LayoutOptions[];
|
||||
}
|
||||
|
||||
const useStyles = makeStyles<BackstageTheme>(() => ({
|
||||
@@ -115,7 +113,6 @@ export const TemplateWizardPage = (props: TemplateWizardPageProps) => {
|
||||
<Stepper
|
||||
manifest={manifest}
|
||||
extensions={props.customFieldExtensions}
|
||||
layouts={props.layouts}
|
||||
/>
|
||||
</InfoCard>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user