diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/AzureSubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/AzureSubForm.jsx index 2af9b8328c..7b3f4b1d00 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/AzureSubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/AzureSubForm.jsx @@ -1,7 +1,7 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; +import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { OptionsField, @@ -27,6 +27,11 @@ const AzureSubForm = ({ autoPopulateCredential, i18n }) => { [setFieldValue] ); + const pluginLink = + 'http://docs.ansible.com/ansible-tower/latest/html/userguide/inventories.html#inventory-plugins'; + const configLink = + 'https://docs.ansible.com/ansible/latest/collections/azure/azcollection/azure_rm_inventory.html'; + return ( <> { - + + + Enter variables to configure the inventory source. For a detailed + description of how to configure this plugin, see{' '} + + Inventory Plugins + {' '} + in the documentation and the{' '} + + azure_rm + {' '} + plugin configuration guide. + +
+
+ + } + /> ); }; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/CloudFormsSubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/CloudFormsSubForm.jsx index 08a47ccbe5..981c67ad90 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/CloudFormsSubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/CloudFormsSubForm.jsx @@ -1,7 +1,7 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; +import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { OptionsField, @@ -27,6 +27,9 @@ const CloudFormsSubForm = ({ i18n }) => { [setFieldValue] ); + const configLink = + 'https://github.com/ansible-collections/community.general/blob/main/scripts/inventory/cloudforms.ini'; + return ( <> { - + + + Override variables found in cloudforms.ini and used by the + inventory update script. For an example variable configuration{' '} + + view cloudforms.ini in the Ansible Collections github repo. + + +
+
+ + } + /> ); }; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/EC2SubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/EC2SubForm.jsx index 3a9ce0806d..d4f41879ba 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/EC2SubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/EC2SubForm.jsx @@ -1,7 +1,7 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; +import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { OptionsField, @@ -23,6 +23,11 @@ const EC2SubForm = ({ i18n }) => { [setFieldValue] ); + const pluginLink = + 'http://docs.ansible.com/ansible-tower/latest/html/userguide/inventories.html#inventory-plugins'; + const configLink = + 'https://docs.ansible.com/ansible/latest/collections/amazon/aws/aws_ec2_inventory.html'; + return ( <> { - + + + Enter variables to configure the inventory source. For a detailed + description of how to configure this plugin, see{' '} + + Inventory Plugins + {' '} + in the documentation and the{' '} + + aws_ec2 + {' '} + plugin configuration guide. + +
+
+ + } + /> ); }; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/GCESubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/GCESubForm.jsx index 8a2bde2f2e..eee39c1d93 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/GCESubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/GCESubForm.jsx @@ -1,7 +1,7 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; +import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { OptionsField, @@ -9,6 +9,7 @@ import { EnabledVarField, EnabledValueField, HostFilterField, + SourceVarsField, } from './SharedFields'; import { required } from '../../../../util/validators'; @@ -26,6 +27,11 @@ const GCESubForm = ({ autoPopulateCredential, i18n }) => { [setFieldValue] ); + const pluginLink = + 'http://docs.ansible.com/ansible-tower/latest/html/userguide/inventories.html#inventory-plugins'; + const configLink = + 'https://docs.ansible.com/ansible/latest/collections/google/cloud/gcp_compute_inventory.html'; + return ( <> { + + + Enter variables to configure the inventory source. For a detailed + description of how to configure this plugin, see{' '} + + Inventory Plugins + {' '} + in the documentation and the{' '} + + gcp_compute + {' '} + plugin configuration guide. + +
+
+ + } + /> ); }; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/GCESubForm.test.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/GCESubForm.test.jsx index 4655d0ad3f..fdbd1aca5e 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/GCESubForm.test.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/GCESubForm.test.jsx @@ -56,6 +56,9 @@ describe('', () => { expect( wrapper.find('FormGroup[label="Cache timeout (seconds)"]') ).toHaveLength(1); + expect( + wrapper.find('VariablesField[label="Source variables"]') + ).toHaveLength(1); }); test('should make expected api calls', () => { diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/OpenStackSubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/OpenStackSubForm.jsx index e778001d5d..7404bfea6e 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/OpenStackSubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/OpenStackSubForm.jsx @@ -1,7 +1,7 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; +import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { OptionsField, @@ -27,6 +27,11 @@ const OpenStackSubForm = ({ autoPopulateCredential, i18n }) => { [setFieldValue] ); + const pluginLink = + 'http://docs.ansible.com/ansible-tower/latest/html/userguide/inventories.html#inventory-plugins'; + const configLink = + 'https://docs.ansible.com/ansible/latest/collections/openstack/cloud/openstack_inventory.html'; + return ( <> { - + + + Enter variables to configure the inventory source. For a detailed + description of how to configure this plugin, see{' '} + + Inventory Plugins + {' '} + in the documentation and the{' '} + + openstack + {' '} + plugin configuration guide. + +
+
+ + } + /> ); }; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SatelliteSubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SatelliteSubForm.jsx index 8bb7387f5c..90dd5e8e0d 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SatelliteSubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SatelliteSubForm.jsx @@ -1,7 +1,7 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; +import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { OptionsField, @@ -27,6 +27,11 @@ const SatelliteSubForm = ({ autoPopulateCredential, i18n }) => { [setFieldValue] ); + const pluginLink = + 'http://docs.ansible.com/ansible-tower/latest/html/userguide/inventories.html#inventory-plugins'; + const configLink = + 'https://docs.ansible.com/ansible/latest/collections/theforeman/foreman/foreman_inventory.html'; + return ( <> { - + + + Enter variables to configure the inventory source. For a detailed + description of how to configure this plugin, see{' '} + + Inventory Plugins + {' '} + in the documentation and the{' '} + + foreman + {' '} + plugin configuration guide. + +
+
+ + } + /> ); }; 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 edd81ae981..6501b2bf4b 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SharedFields.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SharedFields.jsx @@ -1,6 +1,6 @@ import React, { useEffect } from 'react'; import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; +import { t, Trans } from '@lingui/macro'; import { useField } from 'formik'; import { FormGroup } from '@patternfly/react-core'; import { minMaxValue, regExp } from '../../../../util/validators'; @@ -13,15 +13,66 @@ import { } from '../../../../components/FormLayout'; import Popover from '../../../../components/Popover'; -export const SourceVarsField = withI18n()(({ i18n }) => ( - - - -)); +export const SourceVarsField = withI18n()(({ i18n, popoverContent }) => { + const jsonExample = ` + { + "somevar": "somevalue" + "somepassword": "Magic" + } +`; + const yamlExample = ` + --- + somevar: somevalue + somepassword: magic +`; + return ( + + + {popoverContent} + + Enter variables using either JSON or YAML syntax. Use the radio + button to toggle between the two. + +
+
+ JSON: +
{jsonExample}
+
+ YAML: +
{yamlExample}
+
+ + View JSON examples at{' '} + + www.json.org + + +
+ + View YAML examples at{' '} + + docs.ansible.com + + + + } + /> +
+ ); +}); export const VerbosityField = withI18n()(({ i18n }) => { const [field, meta, helpers] = useField('verbosity'); diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/TowerSubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/TowerSubForm.jsx index 1266c740d2..7898e05400 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/TowerSubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/TowerSubForm.jsx @@ -1,7 +1,7 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; +import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { OptionsField, @@ -9,6 +9,7 @@ import { EnabledVarField, EnabledValueField, HostFilterField, + SourceVarsField, } from './SharedFields'; import { required } from '../../../../util/validators'; @@ -26,6 +27,11 @@ const TowerSubForm = ({ autoPopulateCredential, i18n }) => { [setFieldValue] ); + const pluginLink = + 'http://docs.ansible.com/ansible-tower/latest/html/userguide/inventories.html#inventory-plugins'; + const configLink = + 'https://docs.ansible.com/ansible/latest/collections/awx/awx/tower_inventory.html'; + return ( <> { + + + Enter variables to configure the inventory source. For a detailed + description of how to configure this plugin, see{' '} + + Inventory Plugins + {' '} + in the documentation and the{' '} + + Tower + {' '} + plugin configuration guide. + +
+
+ + } + /> ); }; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/TowerSubForm.test.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/TowerSubForm.test.jsx index fd7ee0488a..755566d1ab 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/TowerSubForm.test.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/TowerSubForm.test.jsx @@ -50,6 +50,9 @@ describe('', () => { expect( wrapper.find('FormGroup[label="Cache timeout (seconds)"]') ).toHaveLength(1); + expect( + wrapper.find('VariablesField[label="Source variables"]') + ).toHaveLength(1); }); test('should make expected api calls', () => { diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VMwareSubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VMwareSubForm.jsx index d354b3ed3c..89025d5fd3 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VMwareSubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VMwareSubForm.jsx @@ -1,7 +1,7 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; +import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { OptionsField, @@ -27,6 +27,11 @@ const VMwareSubForm = ({ autoPopulateCredential, i18n }) => { [setFieldValue] ); + const pluginLink = + 'http://docs.ansible.com/ansible-tower/latest/html/userguide/inventories.html#inventory-plugins'; + const configLink = + 'https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_vm_inventory_inventory.html'; + return ( <> { - + + + Enter variables to configure the inventory source. For a detailed + description of how to configure this plugin, see{' '} + + Inventory Plugins + {' '} + in the documentation and the{' '} + + vmware_vm_inventory + {' '} + plugin configuration guide. + +
+
+ + } + /> ); }; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VirtualizationSubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VirtualizationSubForm.jsx index 895650ad8b..d338d1554a 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VirtualizationSubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VirtualizationSubForm.jsx @@ -1,7 +1,7 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; +import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { OptionsField, @@ -9,6 +9,7 @@ import { EnabledVarField, EnabledValueField, HostFilterField, + SourceVarsField, } from './SharedFields'; import { required } from '../../../../util/validators'; @@ -26,6 +27,11 @@ const VirtualizationSubForm = ({ autoPopulateCredential, i18n }) => { [setFieldValue] ); + const pluginLink = + 'http://docs.ansible.com/ansible-tower/latest/html/userguide/inventories.html#inventory-plugins'; + const configLink = + 'https://docs.ansible.com/ansible/latest/collections/ovirt/ovirt/ovirt_inventory.html'; + return ( <> { + + + Enter variables to configure the inventory source. For a detailed + description of how to configure this plugin, see{' '} + + Inventory Plugins + {' '} + in the documentation and the{' '} + + ovirt + {' '} + plugin configuration guide. + +
+
+ + } + /> ); }; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VirtualizationSubForm.test.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VirtualizationSubForm.test.jsx index 35f3933bb9..b6c238735c 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VirtualizationSubForm.test.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VirtualizationSubForm.test.jsx @@ -50,6 +50,9 @@ describe('', () => { expect( wrapper.find('FormGroup[label="Cache timeout (seconds)"]') ).toHaveLength(1); + expect( + wrapper.find('VariablesField[label="Source variables"]') + ).toHaveLength(1); }); test('should make expected api calls', () => {