feat: ui:disabled allowed in RepoUrlPickerHost
Signed-off-by: Nikunj Hudka <nikunjhudka123@gmail.com>
This commit is contained in:
@@ -100,4 +100,31 @@ describe('RepoUrlPickerHostField', () => {
|
||||
|
||||
expect(listbox.getAllByRole('option')).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('disables the host select when isDisabled is true', async () => {
|
||||
const mockOnChange = jest.fn();
|
||||
const mockScaffolderApi = {
|
||||
getIntegrationsList: jest.fn().mockResolvedValue({
|
||||
integrations: [
|
||||
{ host: 'github.com', title: 'github.com', type: 'github' },
|
||||
{ host: 'gitlab.com', title: 'gitlab.com', type: 'gitlab' },
|
||||
],
|
||||
}),
|
||||
};
|
||||
|
||||
const { getByTestId } = await renderInTestApp(
|
||||
<TestApiProvider apis={[[scaffolderApiRef, mockScaffolderApi]]}>
|
||||
<RepoUrlPickerHost
|
||||
hosts={['github.com', 'gitlab.com']}
|
||||
onChange={mockOnChange}
|
||||
rawErrors={[]}
|
||||
isDisabled
|
||||
/>
|
||||
</TestApiProvider>,
|
||||
);
|
||||
|
||||
const selectElement = getByTestId('host-select').querySelector('select');
|
||||
|
||||
expect(selectElement).toBeDisabled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,8 +28,9 @@ export const RepoUrlPickerHost = (props: {
|
||||
hosts?: string[];
|
||||
onChange: (host: string) => void;
|
||||
rawErrors: string[];
|
||||
isDisabled?: boolean;
|
||||
}) => {
|
||||
const { host, hosts, onChange, rawErrors } = props;
|
||||
const { host, hosts, onChange, rawErrors, isDisabled } = props;
|
||||
const { t } = useTranslationRef(scaffolderTranslationRef);
|
||||
const scaffolderApi = useApi(scaffolderApiRef);
|
||||
|
||||
@@ -75,7 +76,7 @@ export const RepoUrlPickerHost = (props: {
|
||||
>
|
||||
<Select
|
||||
native
|
||||
disabled={hosts?.length === 1}
|
||||
disabled={isDisabled || hosts?.length === 1}
|
||||
label={t('fields.repoUrlPicker.host.title')}
|
||||
onChange={s => onChange(String(Array.isArray(s) ? s[0] : s))}
|
||||
selected={host}
|
||||
|
||||
Reference in New Issue
Block a user