From d4044205aa3d2c7487cdb9cf0602fec998a65f27 Mon Sep 17 00:00:00 2001 From: nixocio Date: Tue, 22 Jun 2021 11:45:21 -0400 Subject: [PATCH] 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 --- .../shared/ExecutionEnvironmentForm.jsx | 9 +++- .../shared/ExecutionEnvironmentForm.test.jsx | 42 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/awx/ui_next/src/screens/ExecutionEnvironment/shared/ExecutionEnvironmentForm.jsx b/awx/ui_next/src/screens/ExecutionEnvironment/shared/ExecutionEnvironmentForm.jsx index c2d24642b5ba..ed6a3f0c41e4 100644 --- a/awx/ui_next/src/screens/ExecutionEnvironment/shared/ExecutionEnvironmentForm.jsx +++ b/awx/ui_next/src/screens/ExecutionEnvironment/shared/ExecutionEnvironmentForm.jsx @@ -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} /> {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 ? ( ); diff --git a/awx/ui_next/src/screens/ExecutionEnvironment/shared/ExecutionEnvironmentForm.test.jsx b/awx/ui_next/src/screens/ExecutionEnvironment/shared/ExecutionEnvironmentForm.test.jsx index 57e9364f11a1..dadf06176a49 100644 --- a/awx/ui_next/src/screens/ExecutionEnvironment/shared/ExecutionEnvironmentForm.test.jsx +++ b/awx/ui_next/src/screens/ExecutionEnvironment/shared/ExecutionEnvironmentForm.test.jsx @@ -271,4 +271,46 @@ describe('', () => { 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( + + ); + }); + 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); + }); });