feat: ui:disabled allowed in GerritRepoPicker
Signed-off-by: Nikunj Hudka <nikunjhudka123@gmail.com>
This commit is contained in:
@@ -20,6 +20,23 @@ import { fireEvent } from '@testing-library/react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
|
||||
describe('GerritRepoPicker', () => {
|
||||
it('disables input fields when isDisabled is true', async () => {
|
||||
const { getAllByRole } = await renderInTestApp(
|
||||
<GerritRepoPicker
|
||||
onChange={jest.fn()}
|
||||
rawErrors={[]}
|
||||
state={{}}
|
||||
isDisabled
|
||||
/>,
|
||||
);
|
||||
|
||||
const allInputs = getAllByRole('textbox');
|
||||
|
||||
allInputs.forEach(input => {
|
||||
expect(input).toBeDisabled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('owner input field', () => {
|
||||
it('calls onChange when the owner input changes', async () => {
|
||||
const onChange = jest.fn();
|
||||
|
||||
@@ -21,7 +21,7 @@ import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
||||
import { scaffolderTranslationRef } from '../../../translation';
|
||||
|
||||
export const GerritRepoPicker = (props: BaseRepoUrlPickerProps) => {
|
||||
const { onChange, rawErrors, state } = props;
|
||||
const { onChange, rawErrors, state, isDisabled } = props;
|
||||
const { t } = useTranslationRef(scaffolderTranslationRef);
|
||||
const { workspace, owner } = state;
|
||||
return (
|
||||
@@ -32,6 +32,7 @@ export const GerritRepoPicker = (props: BaseRepoUrlPickerProps) => {
|
||||
label={t('fields.gerritRepoPicker.owner.title')}
|
||||
onChange={e => onChange({ owner: e.target.value })}
|
||||
helperText={t('fields.gerritRepoPicker.owner.description')}
|
||||
disabled={isDisabled}
|
||||
value={owner}
|
||||
/>
|
||||
</FormControl>
|
||||
@@ -44,6 +45,7 @@ export const GerritRepoPicker = (props: BaseRepoUrlPickerProps) => {
|
||||
id="parentInput"
|
||||
label={t('fields.gerritRepoPicker.parent.title')}
|
||||
onChange={e => onChange({ workspace: e.target.value })}
|
||||
disabled={isDisabled}
|
||||
value={workspace}
|
||||
helperText={t('fields.gerritRepoPicker.parent.description')}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user