diff --git a/awx/ui_next/src/components/Lookup/InventoryScriptLookup.jsx b/awx/ui_next/src/components/Lookup/InventoryScriptLookup.jsx deleted file mode 100644 index 3b74d79109..0000000000 --- a/awx/ui_next/src/components/Lookup/InventoryScriptLookup.jsx +++ /dev/null @@ -1,137 +0,0 @@ -import React, { useCallback, useEffect } from 'react'; -import { withRouter } from 'react-router-dom'; -import { func, bool, number, node, string, oneOfType } from 'prop-types'; -import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; - -import { FormGroup } from '@patternfly/react-core'; -import Lookup from './Lookup'; -import LookupErrorMessage from './shared/LookupErrorMessage'; -import OptionsList from '../OptionsList'; -import { InventoriesAPI, InventoryScriptsAPI } from '../../api'; -import { InventoryScript } from '../../types'; -import useRequest from '../../util/useRequest'; -import { getQSConfig, parseQueryString, mergeParams } from '../../util/qs'; - -const QS_CONFIG = getQSConfig('inventory_scripts', { - order_by: 'name', - page: 1, - page_size: 5, - role_level: 'admin_role', -}); - -function InventoryScriptLookup({ - helperTextInvalid, - history, - i18n, - inventoryId, - isValid, - onBlur, - onChange, - required, - value, -}) { - const { - result: { count, inventoryScripts }, - error, - request: fetchInventoryScripts, - } = useRequest( - useCallback(async () => { - const parsedParams = parseQueryString(QS_CONFIG, history.location.search); - const { - data: { organization }, - } = await InventoriesAPI.readDetail(inventoryId); - const { data } = await InventoryScriptsAPI.read( - mergeParams(parsedParams, { organization }) - ); - return { - count: data.count, - inventoryScripts: data.results, - }; - }, [history.location.search, inventoryId]), - { - count: 0, - inventoryScripts: [], - } - ); - - useEffect(() => { - fetchInventoryScripts(); - }, [fetchInventoryScripts]); - - return ( - - ( - dispatch({ type: 'DESELECT_ITEM', item })} - selectItem={item => dispatch({ type: 'SELECT_ITEM', item })} - value={state.selectedItems} - searchColumns={[ - { - name: i18n._(t`Name`), - key: 'name', - isDefault: true, - }, - { - name: i18n._(t`Created By (Username)`), - key: 'created_by__username', - }, - { - name: i18n._(t`Modified By (Username)`), - key: 'modified_by__username', - }, - ]} - sortColumns={[ - { - name: i18n._(t`Name`), - key: 'name', - }, - ]} - /> - )} - /> - - - ); -} - -InventoryScriptLookup.propTypes = { - helperTextInvalid: node, - inventoryId: oneOfType([number, string]).isRequired, - isValid: bool, - onBlur: func, - onChange: func.isRequired, - required: bool, - value: InventoryScript, -}; - -InventoryScriptLookup.defaultProps = { - helperTextInvalid: '', - isValid: true, - onBlur: () => {}, - required: false, - value: null, -}; - -export default withI18n()(withRouter(InventoryScriptLookup)); diff --git a/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx index 46c89b7b4a..6f4204bb67 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx @@ -98,10 +98,6 @@ function PromptInventorySourceDetail({ i18n, resource }) { /> )} - { assertDetail(wrapper, 'Source', 'scm'); assertDetail(wrapper, 'Project', 'Mock Project'); assertDetail(wrapper, 'Inventory File', 'foo'); - assertDetail(wrapper, 'Custom Inventory Script', 'Mock Script'); assertDetail(wrapper, 'Verbosity', '2 (More Verbose)'); assertDetail(wrapper, 'Cache Timeout', '2 Seconds'); expect( diff --git a/awx/ui_next/src/routeConfig.js b/awx/ui_next/src/routeConfig.js index 93c214b10b..08cc6b33cf 100644 --- a/awx/ui_next/src/routeConfig.js +++ b/awx/ui_next/src/routeConfig.js @@ -7,7 +7,6 @@ import Dashboard from './screens/Dashboard'; import Hosts from './screens/Host'; import InstanceGroups from './screens/InstanceGroup'; import Inventory from './screens/Inventory'; -import InventoryScripts from './screens/InventoryScript'; import { Jobs } from './screens/Job'; import ManagementJobs from './screens/ManagementJob'; import NotificationTemplates from './screens/NotificationTemplate'; @@ -79,11 +78,6 @@ function getRouteConfig(i18n) { path: '/hosts', screen: Hosts, }, - { - title: i18n._(t`Inventory Scripts`), - path: '/inventory_scripts', - screen: InventoryScripts, - }, ], }, { diff --git a/awx/ui_next/src/screens/Inventory/InventorySourceAdd/InventorySourceAdd.test.jsx b/awx/ui_next/src/screens/Inventory/InventorySourceAdd/InventorySourceAdd.test.jsx index 85958be52f..5b1d8dcaaa 100644 --- a/awx/ui_next/src/screens/Inventory/InventorySourceAdd/InventorySourceAdd.test.jsx +++ b/awx/ui_next/src/screens/Inventory/InventorySourceAdd/InventorySourceAdd.test.jsx @@ -52,7 +52,6 @@ describe('', () => { ['openstack', 'OpenStack'], ['rhv', 'Red Hat Virtualization'], ['tower', 'Ansible Tower'], - ['custom', 'Custom Script'], ], }, }, diff --git a/awx/ui_next/src/screens/Inventory/InventorySourceDetail/InventorySourceDetail.jsx b/awx/ui_next/src/screens/Inventory/InventorySourceDetail/InventorySourceDetail.jsx index 919d1ec774..42fad28421 100644 --- a/awx/ui_next/src/screens/Inventory/InventorySourceDetail/InventorySourceDetail.jsx +++ b/awx/ui_next/src/screens/Inventory/InventorySourceDetail/InventorySourceDetail.jsx @@ -50,7 +50,6 @@ function InventorySourceDetail({ inventorySource, i18n }) { modified_by, organization, source_project, - source_script, user_capabilities, }, } = inventorySource; @@ -220,10 +219,6 @@ function InventorySourceDetail({ inventorySource, i18n }) { label={i18n._(t`Inventory file`)} value={source_path === '' ? i18n._(t`/ (project root)`) : source_path} /> - { assertDetail(wrapper, 'Ansible environment', '/venv/custom'); assertDetail(wrapper, 'Project', 'Mock Project'); assertDetail(wrapper, 'Inventory file', 'foo'); - assertDetail(wrapper, 'Custom inventory script', 'Mock Script'); assertDetail(wrapper, 'Verbosity', '2 (Debug)'); assertDetail(wrapper, 'Cache timeout', '2 seconds'); expect( diff --git a/awx/ui_next/src/screens/Inventory/InventorySourceEdit/InventorySourceEdit.test.jsx b/awx/ui_next/src/screens/Inventory/InventorySourceEdit/InventorySourceEdit.test.jsx index c37b72c9f6..0d2e88d592 100644 --- a/awx/ui_next/src/screens/Inventory/InventorySourceEdit/InventorySourceEdit.test.jsx +++ b/awx/ui_next/src/screens/Inventory/InventorySourceEdit/InventorySourceEdit.test.jsx @@ -54,7 +54,6 @@ describe('', () => { ['openstack', 'OpenStack'], ['rhv', 'Red Hat Virtualization'], ['tower', 'Ansible Tower'], - ['custom', 'Custom Script'], ], }, }, diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.jsx index 3ffe3aa06e..a694d15243 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.jsx @@ -25,7 +25,6 @@ import { import { AzureSubForm, CloudFormsSubForm, - CustomScriptSubForm, EC2SubForm, GCESubForm, OpenStackSubForm, @@ -173,7 +172,6 @@ const InventorySourceFormFields = ({ sourceOptions, i18n }) => { { azure_rm: , cloudforms: , - custom: , ec2: , gce: , openstack: , diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.test.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.test.jsx index 2eb183f441..829a1c18a0 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.test.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.test.jsx @@ -36,7 +36,6 @@ describe('', () => { ['openstack', 'OpenStack'], ['rhv', 'Red Hat Virtualization'], ['tower', 'Ansible Tower'], - ['custom', 'Custom Script'], ], }, }, diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/CustomScriptSubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/CustomScriptSubForm.jsx deleted file mode 100644 index 2ea29e697f..0000000000 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/CustomScriptSubForm.jsx +++ /dev/null @@ -1,43 +0,0 @@ -import React from 'react'; -import { useField } from 'formik'; -import { useParams } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; -import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; -import InventoryScriptLookup from '../../../../components/Lookup/InventoryScriptLookup'; -import { OptionsField, SourceVarsField, VerbosityField } from './SharedFields'; - -const CustomScriptSubForm = ({ i18n }) => { - const { id } = useParams(); - const [credentialField, , credentialHelpers] = useField('credential'); - const [scriptField, scriptMeta, scriptHelpers] = useField('source_script'); - - return ( - <> - { - credentialHelpers.setValue(value); - }} - /> - scriptHelpers.setTouched()} - onChange={value => { - scriptHelpers.setValue(value); - }} - inventoryId={id} - value={scriptField.value} - required - /> - - - - - ); -}; - -export default withI18n()(CustomScriptSubForm); diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/CustomScriptSubForm.test.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/CustomScriptSubForm.test.jsx deleted file mode 100644 index d71d866c6d..0000000000 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/CustomScriptSubForm.test.jsx +++ /dev/null @@ -1,100 +0,0 @@ -import React from 'react'; -import { act } from 'react-dom/test-utils'; -import { Formik } from 'formik'; -import { mountWithContexts } from '../../../../../testUtils/enzymeHelpers'; -import CustomScriptSubForm from './CustomScriptSubForm'; -import { - CredentialsAPI, - InventoriesAPI, - InventoryScriptsAPI, -} from '../../../../api'; - -jest.mock('../../../../api/models/Credentials'); -jest.mock('../../../../api/models/Inventories'); -jest.mock('../../../../api/models/InventoryScripts'); - -jest.mock('react-router-dom', () => ({ - ...jest.requireActual('react-router-dom'), - useParams: () => ({ - id: 789, - }), -})); - -const initialValues = { - credential: null, - custom_virtualenv: '', - group_by: '', - instance_filters: '', - overwrite: false, - overwrite_vars: false, - source_path: '', - source_project: null, - source_regions: '', - source_script: null, - source_vars: '---\n', - update_cache_timeout: 0, - update_on_launch: true, - update_on_project_update: false, - verbosity: 1, -}; - -describe('', () => { - let wrapper; - CredentialsAPI.read.mockResolvedValue({ - data: { count: 0, results: [] }, - }); - InventoriesAPI.readDetail.mockResolvedValue({ - data: { organization: 123 }, - }); - InventoryScriptsAPI.read.mockResolvedValue({ - data: { count: 0, results: [] }, - }); - - beforeAll(async () => { - await act(async () => { - wrapper = mountWithContexts( - - - - ); - }); - }); - - afterAll(() => { - jest.clearAllMocks(); - wrapper.unmount(); - }); - - test('should render subform fields', () => { - expect(wrapper.find('FormGroup[label="Credential"]')).toHaveLength(1); - expect(wrapper.find('FormGroup[label="Inventory script"]')).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: 'cloud', - order_by: 'name', - page: 1, - page_size: 5, - }); - expect(InventoriesAPI.readDetail).toHaveBeenCalledTimes(1); - expect(InventoriesAPI.readDetail).toHaveBeenCalledWith(789); - expect(InventoryScriptsAPI.read).toHaveBeenCalledTimes(1); - expect(InventoryScriptsAPI.read).toHaveBeenCalledWith({ - organization: 123, - role_level: 'admin_role', - 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 936d646673..324d797d56 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,5 @@ export { default as AzureSubForm } from './AzureSubForm'; export { default as CloudFormsSubForm } from './CloudFormsSubForm'; -export { default as CustomScriptSubForm } from './CustomScriptSubForm'; export { default as EC2SubForm } from './EC2SubForm'; export { default as GCESubForm } from './GCESubForm'; export { default as OpenStackSubForm } from './OpenStackSubForm'; diff --git a/awx/ui_next/src/screens/InventoryScript/InventoryScripts.jsx b/awx/ui_next/src/screens/InventoryScript/InventoryScripts.jsx deleted file mode 100644 index d45f660fa8..0000000000 --- a/awx/ui_next/src/screens/InventoryScript/InventoryScripts.jsx +++ /dev/null @@ -1,28 +0,0 @@ -import React, { Component, Fragment } from 'react'; -import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; -import { - PageSection, - PageSectionVariants, - Title, -} from '@patternfly/react-core'; - -class InventoryScripts extends Component { - render() { - const { i18n } = this.props; - const { light } = PageSectionVariants; - - return ( - - - - {i18n._(t`Inventory Scripts`)} - - - - - ); - } -} - -export default withI18n()(InventoryScripts); diff --git a/awx/ui_next/src/screens/InventoryScript/InventoryScripts.test.jsx b/awx/ui_next/src/screens/InventoryScript/InventoryScripts.test.jsx deleted file mode 100644 index 2c981361bb..0000000000 --- a/awx/ui_next/src/screens/InventoryScript/InventoryScripts.test.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; - -import { mountWithContexts } from '../../../testUtils/enzymeHelpers'; - -import InventoryScripts from './InventoryScripts'; - -describe('', () => { - let pageWrapper; - let pageSections; - let title; - - beforeEach(() => { - pageWrapper = mountWithContexts(); - pageSections = pageWrapper.find('PageSection'); - title = pageWrapper.find('Title'); - }); - - afterEach(() => { - pageWrapper.unmount(); - }); - - test('initially renders without crashing', () => { - expect(pageWrapper.length).toBe(1); - expect(pageSections.length).toBe(2); - expect(title.length).toBe(1); - expect(title.props().size).toBe('2xl'); - expect(pageSections.first().props().variant).toBe('light'); - }); -}); diff --git a/awx/ui_next/src/screens/InventoryScript/index.js b/awx/ui_next/src/screens/InventoryScript/index.js deleted file mode 100644 index 9effeb748e..0000000000 --- a/awx/ui_next/src/screens/InventoryScript/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './InventoryScripts'; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/InventorySourcesList.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/InventorySourcesList.jsx index bcff14d660..132c887fc4 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/InventorySourcesList.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/InventorySourcesList.jsx @@ -85,7 +85,6 @@ function InventorySourcesList({ i18n, nodeResource, onUpdateNodeResource }) { [`openstack`, i18n._(t`OpenStack`)], [`rhv`, i18n._(t`Red Hat Virtualization`)], [`tower`, i18n._(t`Ansible Tower`)], - [`custom`, i18n._(t`Custom script`)], ], }, ]}