Skip to content

Commit

Permalink
Merge pull request ansible#5125 from ansible/ui_issue_5016
Browse files Browse the repository at this point in the history
Disable edit fields for managed EE, except pull
  • Loading branch information
Mat Wilson authored Jun 22, 2021
2 parents 7ff0318 + d404420 commit e5fc5a6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand All @@ -93,6 +96,7 @@ function ExecutionEnvironmentFormFields({
type="text"
validate={required(null)}
isRequired
isDisabled={executionEnvironment?.managed || false}
/>
<FormField
id="execution-environment-image"
Expand All @@ -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.`}
Expand Down Expand Up @@ -142,6 +147,7 @@ function ExecutionEnvironmentFormFields({
label={t`Description`}
name="description"
type="text"
isDisabled={executionEnvironment?.managed || false}
/>
{isOrgLookupDisabled && isGloballyAvailable.current ? (
<Tooltip
Expand All @@ -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}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit e5fc5a6

Please sign in to comment.