mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Fixes silent error on SCM subform
This commit is contained in:
@@ -140,4 +140,63 @@ describe('<SCMSubForm />', () => {
|
|||||||
customWrapper.update();
|
customWrapper.update();
|
||||||
expect(customWrapper.find('Select').prop('selections')).toBe('newPath/');
|
expect(customWrapper.find('Select').prop('selections')).toBe('newPath/');
|
||||||
});
|
});
|
||||||
|
test('Update on project update should be disabled', async () => {
|
||||||
|
const customInitialValues = {
|
||||||
|
credential: { id: 1, name: 'Credential' },
|
||||||
|
custom_virtualenv: '',
|
||||||
|
overwrite: false,
|
||||||
|
overwrite_vars: false,
|
||||||
|
source_path: '/path',
|
||||||
|
source_project: { id: 1, name: 'Source project' },
|
||||||
|
source_script: null,
|
||||||
|
source_vars: '---\n',
|
||||||
|
update_cache_timeout: 0,
|
||||||
|
update_on_launch: true,
|
||||||
|
update_on_project_update: false,
|
||||||
|
verbosity: 1,
|
||||||
|
};
|
||||||
|
let customWrapper;
|
||||||
|
await act(async () => {
|
||||||
|
customWrapper = mountWithContexts(
|
||||||
|
<Formik initialValues={customInitialValues}>
|
||||||
|
<SCMSubForm />
|
||||||
|
</Formik>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
customWrapper
|
||||||
|
.find('Checkbox[aria-label="Update on project update"]')
|
||||||
|
.prop('isDisabled')
|
||||||
|
).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Update on launch should be disabled', async () => {
|
||||||
|
const customInitialValues = {
|
||||||
|
credential: { id: 1, name: 'Credential' },
|
||||||
|
custom_virtualenv: '',
|
||||||
|
overwrite: false,
|
||||||
|
overwrite_vars: false,
|
||||||
|
source_path: '/path',
|
||||||
|
source_project: { id: 1, name: 'Source project' },
|
||||||
|
source_script: null,
|
||||||
|
source_vars: '---\n',
|
||||||
|
update_cache_timeout: 0,
|
||||||
|
update_on_launch: false,
|
||||||
|
update_on_project_update: true,
|
||||||
|
verbosity: 1,
|
||||||
|
};
|
||||||
|
let customWrapper;
|
||||||
|
await act(async () => {
|
||||||
|
customWrapper = mountWithContexts(
|
||||||
|
<Formik initialValues={customInitialValues}>
|
||||||
|
<SCMSubForm />
|
||||||
|
</Formik>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
customWrapper
|
||||||
|
.find('Checkbox[aria-label="Update on launch"]')
|
||||||
|
.prop('isDisabled')
|
||||||
|
).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { useEffect } from 'react';
|
|||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t, Trans } from '@lingui/macro';
|
import { t, Trans } from '@lingui/macro';
|
||||||
import { useField } from 'formik';
|
import { useField } from 'formik';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
import { FormGroup } from '@patternfly/react-core';
|
import { FormGroup } from '@patternfly/react-core';
|
||||||
import { minMaxValue, regExp } from '../../../../util/validators';
|
import { minMaxValue, regExp } from '../../../../util/validators';
|
||||||
import AnsibleSelect from '../../../../components/AnsibleSelect';
|
import AnsibleSelect from '../../../../components/AnsibleSelect';
|
||||||
@@ -108,6 +109,8 @@ export const OptionsField = withI18n()(
|
|||||||
({ i18n, showProjectUpdate = false }) => {
|
({ i18n, showProjectUpdate = false }) => {
|
||||||
const [updateOnLaunchField] = useField('update_on_launch');
|
const [updateOnLaunchField] = useField('update_on_launch');
|
||||||
const [, , updateCacheTimeoutHelper] = useField('update_cache_timeout');
|
const [, , updateCacheTimeoutHelper] = useField('update_cache_timeout');
|
||||||
|
const [updatedOnProjectUpdateField] = useField('update_on_project_update');
|
||||||
|
const [projectField] = useField('source_project');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!updateOnLaunchField.value) {
|
if (!updateOnLaunchField.value) {
|
||||||
@@ -162,22 +165,62 @@ export const OptionsField = withI18n()(
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<CheckboxField
|
<CheckboxField
|
||||||
|
isDisabled={updatedOnProjectUpdateField.value}
|
||||||
id="update_on_launch"
|
id="update_on_launch"
|
||||||
name="update_on_launch"
|
name="update_on_launch"
|
||||||
label={i18n._(t`Update on launch`)}
|
label={i18n._(t`Update on launch`)}
|
||||||
tooltip={i18n._(t`Each time a job runs using this inventory,
|
tooltip={
|
||||||
|
<>
|
||||||
|
<div>
|
||||||
|
{i18n._(t`Each time a job runs using this inventory,
|
||||||
refresh the inventory from the selected source before
|
refresh the inventory from the selected source before
|
||||||
executing job tasks.`)}
|
executing job tasks.`)}
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
{projectField?.value && (
|
||||||
|
<div>
|
||||||
|
{i18n._(t`If you want the Inventory Source to update on
|
||||||
|
launch and on project update, click on Update on launch, and also go to`)}
|
||||||
|
<Link to={`/projects/${projectField.value.id}/details`}>
|
||||||
|
{' '}
|
||||||
|
{projectField.value.name}{' '}
|
||||||
|
</Link>
|
||||||
|
{i18n._(t`and click on Update Revision on Launch`)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
{showProjectUpdate && (
|
{showProjectUpdate && (
|
||||||
<CheckboxField
|
<CheckboxField
|
||||||
|
isDisabled={updateOnLaunchField.value}
|
||||||
id="update_on_project_update"
|
id="update_on_project_update"
|
||||||
name="update_on_project_update"
|
name="update_on_project_update"
|
||||||
label={i18n._(t`Update on project update`)}
|
label={i18n._(t`Update on project update`)}
|
||||||
tooltip={i18n._(t`After every project update where the SCM revision
|
tooltip={
|
||||||
|
<>
|
||||||
|
<div>
|
||||||
|
{i18n._(t`After every project update where the SCM revision
|
||||||
changes, refresh the inventory from the selected source
|
changes, refresh the inventory from the selected source
|
||||||
before executing job tasks. This is intended for static content,
|
before executing job tasks. This is intended for static content,
|
||||||
like the Ansible inventory .ini file format.`)}
|
like the Ansible inventory .ini file format.`)}
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
{projectField?.value && (
|
||||||
|
<div>
|
||||||
|
{i18n._(t`If you want the Inventory Source to update on
|
||||||
|
launch and on project update, click on Update on launch, and also go to`)}
|
||||||
|
<Link
|
||||||
|
to={`/projects/${projectField.value.id}/details`}
|
||||||
|
>
|
||||||
|
{' '}
|
||||||
|
{projectField.value.name}{' '}
|
||||||
|
</Link>
|
||||||
|
{i18n._(t`and click on Update Revision on Launch`)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</FormCheckboxLayout>
|
</FormCheckboxLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user