Merge pull request #20524 from fedy97/hotfix/show-title-descr-repourlpicker

fix: title and description are now correctly displayed in RepoUrlPicker
This commit is contained in:
Ben Lambert
2023-10-27 15:19:38 +02:00
committed by GitHub
3 changed files with 48 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder': patch
---
Title and description in RepoUrlPicker are now correctly displayed.
@@ -132,6 +132,38 @@ describe('RepoUrlPicker', () => {
getByRole('option', { name: 'dev.azure.com' }),
).toBeInTheDocument();
});
it('should render properly with title and description', async () => {
const { getByText } = await renderInTestApp(
<TestApiProvider
apis={[
[scmIntegrationsApiRef, mockIntegrationsApi],
[scmAuthApiRef, {}],
[scaffolderApiRef, mockScaffolderApi],
]}
>
<SecretsContextProvider>
<Form
validator={validator}
schema={{
type: 'string',
title: 'test title',
description: 'test description',
}}
uiSchema={{
'ui:field': 'RepoUrlPicker',
}}
fields={{
RepoUrlPicker: RepoUrlPicker as ScaffolderRJSFField<string>,
}}
/>
</SecretsContextProvider>
</TestApiProvider>,
);
expect(getByText('test title')).toBeInTheDocument();
expect(getByText('test description')).toBeInTheDocument();
});
});
describe('requestUserCredentials', () => {
@@ -31,6 +31,7 @@ import { RepoUrlPickerProps } from './schema';
import { RepoUrlPickerState } from './types';
import useDebounce from 'react-use/lib/useDebounce';
import { useTemplateSecrets } from '@backstage/plugin-scaffolder-react';
import { Box, Divider, Typography } from '@material-ui/core';
export { RepoUrlPickerSchema } from './schema';
@@ -41,7 +42,7 @@ export { RepoUrlPickerSchema } from './schema';
* @public
*/
export const RepoUrlPicker = (props: RepoUrlPickerProps) => {
const { uiSchema, onChange, rawErrors, formData } = props;
const { uiSchema, onChange, rawErrors, formData, schema } = props;
const [state, setState] = useState<RepoUrlPickerState>(
parseRepoPickerUrl(formData),
);
@@ -157,9 +158,17 @@ export const RepoUrlPicker = (props: RepoUrlPickerProps) => {
const hostType =
(state.host && integrationApi.byHost(state.host)?.type) ?? null;
return (
<>
{schema.title && (
<Box my={1}>
<Typography variant="h5">{schema.title}</Typography>
<Divider />
</Box>
)}
{schema.description && (
<Typography variant="body1">{schema.description}</Typography>
)}
<RepoUrlPickerHost
host={state.host}
hosts={allowedHosts}