From 10d95c9aefe016f62fb077220898640a15cb8ae7 Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Fri, 12 Mar 2021 15:05:06 -0500 Subject: [PATCH 1/2] Fixes silent error on SCM subform --- .../SCMSubForm.test.jsx | 59 +++++++++++++++++++ .../InventorySourceSubForms/SharedFields.jsx | 47 ++++++++++++++- 2 files changed, 104 insertions(+), 2 deletions(-) diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SCMSubForm.test.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SCMSubForm.test.jsx index 2a35508120..0d3c47f451 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SCMSubForm.test.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SCMSubForm.test.jsx @@ -140,4 +140,63 @@ describe('', () => { customWrapper.update(); 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( + + + + ); + }); + 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( + + + + ); + }); + expect( + customWrapper + .find('Checkbox[aria-label="Update on launch"]') + .prop('isDisabled') + ).toBe(true); + }); }); diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SharedFields.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SharedFields.jsx index 31f5a4f12e..36ab5ca3c9 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SharedFields.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SharedFields.jsx @@ -2,6 +2,7 @@ import React, { useEffect } from 'react'; import { withI18n } from '@lingui/react'; import { t, Trans } from '@lingui/macro'; import { useField } from 'formik'; +import { Link } from 'react-router-dom'; import { FormGroup } from '@patternfly/react-core'; import { minMaxValue, regExp } from '../../../../util/validators'; import AnsibleSelect from '../../../../components/AnsibleSelect'; @@ -108,6 +109,8 @@ export const OptionsField = withI18n()( ({ i18n, showProjectUpdate = false }) => { const [updateOnLaunchField] = useField('update_on_launch'); const [, , updateCacheTimeoutHelper] = useField('update_cache_timeout'); + const [updatedOnProjectUpdateField] = useField('update_on_project_update'); + const [projectField] = useField('source_project'); useEffect(() => { if (!updateOnLaunchField.value) { @@ -162,22 +165,62 @@ export const OptionsField = withI18n()( } /> +
+ {i18n._(t`Each time a job runs using this inventory, refresh the inventory from the selected source before executing job tasks.`)} +
+
+ {projectField?.value && ( +
+ {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`)} + + {' '} + {projectField.value.name}{' '} + + {i18n._(t`and click on Update Revision on Launch`)} +
+ )} + + } /> {showProjectUpdate && ( +
+ {i18n._(t`After every project update where the SCM revision changes, refresh the inventory from the selected source before executing job tasks. This is intended for static content, like the Ansible inventory .ini file format.`)} +
+
+ {projectField?.value && ( +
+ {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`)} + + {' '} + {projectField.value.name}{' '} + + {i18n._(t`and click on Update Revision on Launch`)} +
+ )} + + } /> )} From 7290de22e2f04ffdb13d45eaed4cce152986e70a Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Wed, 17 Mar 2021 15:38:58 -0400 Subject: [PATCH 2/2] addes better tooltip selector --- awx/ui_next/src/components/FormField/CheckboxField.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui_next/src/components/FormField/CheckboxField.jsx b/awx/ui_next/src/components/FormField/CheckboxField.jsx index 2a43675dae..57dd17c9b9 100644 --- a/awx/ui_next/src/components/FormField/CheckboxField.jsx +++ b/awx/ui_next/src/components/FormField/CheckboxField.jsx @@ -22,7 +22,7 @@ function CheckboxField({ {label}   - {tooltip && } + {tooltip && } } id={id}