diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.jsx
index a6b637a44a..aa3fc78266 100644
--- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.jsx
+++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.jsx
@@ -20,6 +20,7 @@ import {
AzureSubForm,
EC2SubForm,
GCESubForm,
+ InsightsSubForm,
OpenStackSubForm,
SCMSubForm,
SatelliteSubForm,
@@ -179,6 +180,13 @@ const InventorySourceFormFields = ({
sourceOptions={sourceOptions}
/>
),
+ insights: (
+
+ ),
openstack: (
{
+ const { setFieldValue, setFieldTouched } = useFormikContext();
+ const [credentialField, credentialMeta, credentialHelpers] = useField(
+ 'credential'
+ );
+ const config = useConfig();
+
+ const handleCredentialUpdate = useCallback(
+ value => {
+ setFieldValue('credential', value);
+ setFieldTouched('credential', true, false);
+ },
+ [setFieldValue, setFieldTouched]
+ );
+
+ const pluginLink = `${getDocsBaseUrl(
+ config
+ )}/html/userguide/inventories.html#inventory-plugins`;
+ const configLink =
+ 'https://docs.ansible.com/ansible/latest/collections/redhatinsights/insights/insights_inventory.html';
+
+ return (
+ <>
+ credentialHelpers.setTouched()}
+ onChange={handleCredentialUpdate}
+ value={credentialField.value}
+ required
+ autoPopulate={autoPopulateCredential}
+ validate={required(t`Select a value for this field`)}
+ />
+
+
+
+
+
+
+
+ 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{' '}
+
+ Insights
+ {' '}
+ plugin configuration guide.
+
+
+
+ >
+ }
+ />
+ >
+ );
+};
+
+export default InsightsSubForm;
diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/InsightsSubForm.test.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/InsightsSubForm.test.jsx
new file mode 100644
index 0000000000..9db84e617f
--- /dev/null
+++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/InsightsSubForm.test.jsx
@@ -0,0 +1,65 @@
+import React from 'react';
+import { act } from 'react-dom/test-utils';
+import { Formik } from 'formik';
+import { mountWithContexts } from '../../../../../testUtils/enzymeHelpers';
+import InsightsSubForm from './InsightsSubForm';
+import { CredentialsAPI } from '../../../../api';
+
+jest.mock('../../../../api');
+
+const initialValues = {
+ credential: null,
+ overwrite: false,
+ overwrite_vars: false,
+ source_path: '',
+ source_project: null,
+ source_script: null,
+ source_vars: '---\n',
+ update_cache_timeout: 0,
+ update_on_launch: true,
+ update_on_project_update: false,
+ verbosity: 1,
+};
+
+describe('', () => {
+ let wrapper;
+
+ beforeEach(async () => {
+ CredentialsAPI.read.mockResolvedValue({
+ data: { count: 0, results: [] },
+ });
+ await act(async () => {
+ wrapper = mountWithContexts(
+
+
+
+ );
+ });
+ });
+
+ afterAll(() => {
+ jest.clearAllMocks();
+ });
+
+ test('should render subform fields', () => {
+ expect(wrapper.find('FormGroup[label="Credential"]')).toHaveLength(1);
+ expect(wrapper.find('FormGroup[label="Verbosity"]')).toHaveLength(1);
+ expect(wrapper.find('FormGroup[label="Update options"]')).toHaveLength(1);
+ 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', () => {
+ expect(CredentialsAPI.read).toHaveBeenCalledTimes(1);
+ expect(CredentialsAPI.read).toHaveBeenCalledWith({
+ credential_type__namespace: 'insights',
+ order_by: 'name',
+ page: 1,
+ page_size: 5,
+ });
+ });
+});
diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/index.js b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/index.js
index b7e8c15971..2efe263db7 100644
--- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/index.js
+++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/index.js
@@ -1,6 +1,7 @@
export { default as AzureSubForm } from './AzureSubForm';
export { default as EC2SubForm } from './EC2SubForm';
export { default as GCESubForm } from './GCESubForm';
+export { default as InsightsSubForm } from './InsightsSubForm';
export { default as OpenStackSubForm } from './OpenStackSubForm';
export { default as SCMSubForm } from './SCMSubForm';
export { default as SatelliteSubForm } from './SatelliteSubForm';