mirror of
https://github.com/ansible/awx.git
synced 2026-03-18 17:37:30 -02:30
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:
@@ -74,7 +74,10 @@ function ExecutionEnvironmentFormFields({
|
|||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
autoPopulate={!me?.is_superuser ? !executionEnvironment?.id : null}
|
autoPopulate={!me?.is_superuser ? !executionEnvironment?.id : null}
|
||||||
isDisabled={!!isOrgLookupDisabled && isGloballyAvailable.current}
|
isDisabled={
|
||||||
|
(!!isOrgLookupDisabled && isGloballyAvailable.current) ||
|
||||||
|
executionEnvironment?.managed
|
||||||
|
}
|
||||||
validate={
|
validate={
|
||||||
!me?.is_superuser
|
!me?.is_superuser
|
||||||
? required(t`Select a value for this field`)
|
? required(t`Select a value for this field`)
|
||||||
@@ -93,6 +96,7 @@ function ExecutionEnvironmentFormFields({
|
|||||||
type="text"
|
type="text"
|
||||||
validate={required(null)}
|
validate={required(null)}
|
||||||
isRequired
|
isRequired
|
||||||
|
isDisabled={executionEnvironment?.managed || false}
|
||||||
/>
|
/>
|
||||||
<FormField
|
<FormField
|
||||||
id="execution-environment-image"
|
id="execution-environment-image"
|
||||||
@@ -101,6 +105,7 @@ function ExecutionEnvironmentFormFields({
|
|||||||
type="text"
|
type="text"
|
||||||
validate={required(null)}
|
validate={required(null)}
|
||||||
isRequired
|
isRequired
|
||||||
|
isDisabled={executionEnvironment?.managed || false}
|
||||||
tooltip={
|
tooltip={
|
||||||
<span>
|
<span>
|
||||||
{t`The full image location, including the container registry, image name, and version tag.`}
|
{t`The full image location, including the container registry, image name, and version tag.`}
|
||||||
@@ -142,6 +147,7 @@ function ExecutionEnvironmentFormFields({
|
|||||||
label={t`Description`}
|
label={t`Description`}
|
||||||
name="description"
|
name="description"
|
||||||
type="text"
|
type="text"
|
||||||
|
isDisabled={executionEnvironment?.managed || false}
|
||||||
/>
|
/>
|
||||||
{isOrgLookupDisabled && isGloballyAvailable.current ? (
|
{isOrgLookupDisabled && isGloballyAvailable.current ? (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
@@ -162,6 +168,7 @@ function ExecutionEnvironmentFormFields({
|
|||||||
onChange={onCredentialChange}
|
onChange={onCredentialChange}
|
||||||
value={credentialField.value}
|
value={credentialField.value}
|
||||||
tooltip={t`Credential to authenticate with a protected container registry.`}
|
tooltip={t`Credential to authenticate with a protected container registry.`}
|
||||||
|
isDisabled={executionEnvironment?.managed || false}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -271,4 +271,46 @@ describe('<ExecutionEnvironmentForm/>', () => {
|
|||||||
newWrapper.update();
|
newWrapper.update();
|
||||||
expect(newWrapper.find('OrganizationLookup').prop('value')).toEqual(null);
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user