diff --git a/.changeset/wise-wasps-look.md b/.changeset/wise-wasps-look.md new file mode 100644 index 0000000000..34f52b3a7b --- /dev/null +++ b/.changeset/wise-wasps-look.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder': patch +--- + +Change owner to project for azure host diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/AzureRepoPicker.test.tsx b/plugins/scaffolder/src/components/fields/RepoUrlPicker/AzureRepoPicker.test.tsx index eb77240d33..0380ac6ce8 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/AzureRepoPicker.test.tsx +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/AzureRepoPicker.test.tsx @@ -44,18 +44,18 @@ describe('AzureRepoPicker', () => { }); }); - describe('owner field', () => { - it('calls onChange when the owner changes', () => { + describe('project field', () => { + it('calls onChange when the project changes', () => { const onChange = jest.fn(); const { getAllByRole } = render( , ); - const ownerInput = getAllByRole('textbox')[1]; + const projectInput = getAllByRole('textbox')[1]; - fireEvent.change(ownerInput, { target: { value: 'owner' } }); + fireEvent.change(projectInput, { target: { value: 'project' } }); - expect(onChange).toHaveBeenCalledWith({ owner: 'owner' }); + expect(onChange).toHaveBeenCalledWith({ project: 'project' }); }); }); }); diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/AzureRepoPicker.tsx b/plugins/scaffolder/src/components/fields/RepoUrlPicker/AzureRepoPicker.tsx index 83f013c8b4..833a0849fb 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/AzureRepoPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/AzureRepoPicker.tsx @@ -24,14 +24,14 @@ import { Select, SelectItem } from '@backstage/core-components'; export const AzureRepoPicker = (props: { allowedOrganizations?: string[]; - allowedOwners?: string[]; + allowedProject?: string[]; rawErrors: string[]; state: RepoUrlPickerState; onChange: (state: RepoUrlPickerState) => void; }) => { const { allowedOrganizations = [], - allowedOwners = [], + allowedProject = [], rawErrors, state, onChange, @@ -41,11 +41,11 @@ export const AzureRepoPicker = (props: { ? allowedOrganizations.map(i => ({ label: i, value: i })) : [{ label: 'Loading...', value: 'loading' }]; - const ownerItems: SelectItem[] = allowedOwners - ? allowedOwners.map(i => ({ label: i, value: i })) + const projectItems: SelectItem[] = allowedProject + ? allowedProject.map(i => ({ label: i, value: i })) : [{ label: 'Loading...', value: 'loading' }]; - const { organization, owner } = state; + const { organization, project } = state; return ( <> @@ -82,26 +82,26 @@ export const AzureRepoPicker = (props: { 0 && !owner} + error={rawErrors?.length > 0 && !project} > - {allowedOwners?.length ? ( + {allowedProject?.length ? ( onChange({ owner: e.target.value })} - value={owner} + id="projectInput" + onChange={e => onChange({ project: e.target.value })} + value={project} /> )} diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.test.tsx b/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.test.tsx index 85a50fa7cb..1fa723c8c6 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.test.tsx +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.test.tsx @@ -58,6 +58,10 @@ describe('RepoUrlPicker', () => { byHost: () => ({ type: 'github' }), }; + const mockIntegrationsApiAzure: Partial = { + byHost: () => ({ type: 'azure' }), + }; + let mockScmAuthApi: Partial; beforeEach(() => { @@ -111,7 +115,7 @@ describe('RepoUrlPicker', () => { const { getByRole } = await renderInTestApp( { ).toBeInTheDocument(); }); + it('should render properly with allowedProject', async () => { + const { getByRole } = await renderInTestApp( + + +
, + }} + /> + + , + ); + + expect(getByRole('option', { name: 'Backstage' })).toBeInTheDocument(); + }); + it('should render properly with title and description', async () => { const { getByText } = await renderInTestApp( { {hostType === 'azure' && (