From 61ce8cb029bc39a3b2415a40eb308b75507fabae Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Thu, 6 Aug 2020 11:47:50 -0400 Subject: [PATCH] delete inadverdently added back InventoryScriptLookup file --- .../Lookup/InventoryScriptLookup.jsx | 156 ------------------ 1 file changed, 156 deletions(-) delete mode 100644 awx/ui_next/src/components/Lookup/InventoryScriptLookup.jsx 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 d5638fc831..0000000000 --- a/awx/ui_next/src/components/Lookup/InventoryScriptLookup.jsx +++ /dev/null @@ -1,156 +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, actions, relatedSearchFields }, - error, - request: fetchInventoryScripts, - } = useRequest( - useCallback(async () => { - const parsedParams = parseQueryString(QS_CONFIG, history.location.search); - const [ - { - data: { organization }, - }, - actionsResponse, - ] = await Promise.all([ - InventoriesAPI.readDetail(inventoryId), - InventoriesAPI.readOptions(), - ]); - const { data } = await InventoryScriptsAPI.read( - mergeParams(parsedParams, { organization }) - ); - return { - count: data.count, - inventoryScripts: data.results, - actions: actionsResponse.data.actions, - relatedSearchFields: ( - actionsResponse?.data?.related_search_fields || [] - ).map(val => val.slice(0, -8)), - }; - }, [history.location.search, inventoryId]), - { - count: 0, - inventoryScripts: [], - actions: {}, - relatedSearchFields: [], - } - ); - - useEffect(() => { - fetchInventoryScripts(); - }, [fetchInventoryScripts]); - - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - - return ( - - ( - dispatch({ type: 'DESELECT_ITEM', item })} - selectItem={item => dispatch({ type: 'SELECT_ITEM', item })} - value={state.selectedItems} - searchColumns={[ - { - name: i18n._(t`Name`), - key: 'name__icontains', - isDefault: true, - }, - { - name: i18n._(t`Created By (Username)`), - key: 'created_by__username__icontains', - }, - { - name: i18n._(t`Modified By (Username)`), - key: 'modified_by__username__icontains', - }, - ]} - sortColumns={[ - { - name: i18n._(t`Name`), - key: 'name', - }, - ]} - searchableKeys={searchableKeys} - relatedSearchableKeys={relatedSearchableKeys} - /> - )} - /> - - - ); -} - -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));