Disable edit fields for managed EE, except pull

Disable edit fields for managed EE, except pull options.

See: https://github.com/ansible/tower/issues/5016
This commit is contained in:
nixocio 2021-06-22 11:45:21 -04:00 committed by Shane McDonald
parent 487d78cc72
commit 77b0b9a4e3
No known key found for this signature in database
GPG Key ID: 6F374AF6E9EB9374
2 changed files with 50 additions and 1 deletions

View File

@ -74,7 +74,10 @@ function ExecutionEnvironmentFormFields({
: null
}
autoPopulate={!me?.is_superuser ? !executionEnvironment?.id : null}
isDisabled={!!isOrgLookupDisabled && isGloballyAvailable.current}
isDisabled={
(!!isOrgLookupDisabled && isGloballyAvailable.current) ||
executionEnvironment?.managed
}
validate={
!me?.is_superuser
? required(t`Select a value for this field`)
@ -93,6 +96,7 @@ function ExecutionEnvironmentFormFields({
type="text"
validate={required(null)}
isRequired
isDisabled={executionEnvironment?.managed || false}
/>
<FormField
id="execution-environment-image"
@ -101,6 +105,7 @@ function ExecutionEnvironmentFormFields({
type="text"
validate={required(null)}
isRequired
isDisabled={executionEnvironment?.managed || false}
tooltip={
<span>
{t`The full image location, including the container registry, image name, and version tag.`}
@ -142,6 +147,7 @@ function ExecutionEnvironmentFormFields({
label={t`Description`}
name="description"
type="text"
isDisabled={executionEnvironment?.managed || false}
/>
{isOrgLookupDisabled && isGloballyAvailable.current ? (
<Tooltip
@ -162,6 +168,7 @@ function ExecutionEnvironmentFormFields({
onChange={onCredentialChange}
value={credentialField.value}
tooltip={t`Credential to authenticate with a protected container registry.`}
isDisabled={executionEnvironment?.managed || false}
/>
</>
);

View File

@ -271,4 +271,46 @@ describe('<ExecutionEnvironmentForm/>', () => {
newWrapper.update();
expect(newWrapper.find('OrganizationLookup').prop('value')).toEqual(null);
});
test('should disable edition for managed EEs, except pull option', async () => {
let newWrapper;
await act(async () => {
newWrapper = mountWithContexts(
<ExecutionEnvironmentForm
onCancel={onCancel}
onSubmit={onSubmit}
executionEnvironment={{ ...executionEnvironment, managed: true }}
options={mockOptions}
me={mockMe}
/>
);
});
await waitForElement(newWrapper, 'ContentLoading', el => el.length === 0);
expect(newWrapper.find('OrganizationLookup').prop('isDisabled')).toEqual(
true
);
expect(newWrapper.find('CredentialLookup').prop('isDisabled')).toEqual(
true
);
expect(
newWrapper
.find('TextInputBase[id="execution-environment-name"]')
.prop('isDisabled')
).toEqual(true);
expect(
newWrapper
.find('TextInputBase[id="execution-environment-description"]')
.prop('isDisabled')
).toEqual(true);
expect(
newWrapper
.find('TextInputBase[id="execution-environment-image"]')
.prop('isDisabled')
).toEqual(true);
expect(
newWrapper
.find('FormSelect[id="container-pull-options"]')
.prop('isDisabled')
).toEqual(false);
});
});