feat: ui:disabled allowed in AzureRepoPicker
Signed-off-by: Nikunj Hudka <nikunjhudka123@gmail.com>
This commit is contained in:
@@ -30,6 +30,23 @@ describe('AzureRepoPicker', () => {
|
||||
expect(allInputs).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('disables input fields when isDisabled is true', async () => {
|
||||
const { getAllByRole } = await renderInTestApp(
|
||||
<AzureRepoPicker
|
||||
onChange={jest.fn()}
|
||||
rawErrors={[]}
|
||||
state={{}}
|
||||
isDisabled
|
||||
/>,
|
||||
);
|
||||
|
||||
const allInputs = getAllByRole('textbox');
|
||||
|
||||
allInputs.forEach(input => {
|
||||
expect(input).toBeDisabled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('org field', () => {
|
||||
it('calls onChange when the organisation changes', async () => {
|
||||
const onChange = jest.fn();
|
||||
|
||||
@@ -35,6 +35,7 @@ export const AzureRepoPicker = (
|
||||
rawErrors,
|
||||
state,
|
||||
onChange,
|
||||
isDisabled,
|
||||
} = props;
|
||||
const { t } = useTranslationRef(scaffolderTranslationRef);
|
||||
|
||||
@@ -63,7 +64,7 @@ export const AzureRepoPicker = (
|
||||
onChange={s =>
|
||||
onChange({ organization: String(Array.isArray(s) ? s[0] : s) })
|
||||
}
|
||||
disabled={allowedOrganizations.length === 1}
|
||||
disabled={isDisabled || allowedOrganizations.length === 1}
|
||||
selected={organization}
|
||||
items={organizationItems}
|
||||
/>
|
||||
@@ -77,6 +78,7 @@ export const AzureRepoPicker = (
|
||||
label={t('fields.azureRepoPicker.organization.title')}
|
||||
onChange={e => onChange({ organization: e.target.value })}
|
||||
helperText={t('fields.azureRepoPicker.organization.description')}
|
||||
disabled={isDisabled}
|
||||
value={organization}
|
||||
/>
|
||||
)}
|
||||
@@ -94,7 +96,7 @@ export const AzureRepoPicker = (
|
||||
onChange={s =>
|
||||
onChange({ project: String(Array.isArray(s) ? s[0] : s) })
|
||||
}
|
||||
disabled={allowedProject.length === 1}
|
||||
disabled={isDisabled || allowedProject.length === 1}
|
||||
selected={project}
|
||||
items={projectItems}
|
||||
/>
|
||||
@@ -108,6 +110,7 @@ export const AzureRepoPicker = (
|
||||
label={t('fields.azureRepoPicker.project.title')}
|
||||
onChange={e => onChange({ project: e.target.value })}
|
||||
value={project}
|
||||
disabled={isDisabled}
|
||||
helperText={t('fields.azureRepoPicker.project.description')}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user