diff --git a/awx/ui/src/components/AddRole/SelectResourceStep.js b/awx/ui/src/components/AddRole/SelectResourceStep.js index f41f179554..b0e8897320 100644 --- a/awx/ui/src/components/AddRole/SelectResourceStep.js +++ b/awx/ui/src/components/AddRole/SelectResourceStep.js @@ -8,7 +8,11 @@ import { getQSConfig, parseQueryString } from 'util/qs'; import DataListToolbar from '../DataListToolbar'; import CheckboxListItem from '../CheckboxListItem'; import { SelectedList } from '../SelectedList'; -import PaginatedTable, { HeaderCell, HeaderRow } from '../PaginatedTable'; +import PaginatedTable, { + HeaderCell, + HeaderRow, + getSearchableKeys, +} from '../PaginatedTable'; const QS_Config = (sortColumns) => getQSConfig('resource', { @@ -56,9 +60,7 @@ function SelectResourceStep({ relatedSearchableKeys: ( actionsResponse?.data?.related_search_fields || [] ).map((val) => val.slice(0, -8)), - searchableKeys: Object.keys( - actionsResponse.data.actions?.GET || {} - ).filter((key) => actionsResponse.data.actions?.GET[key].filterable), + searchableKeys: getSearchableKeys(actionsResponse.data.actions?.GET), }; }, [location, fetchItems, fetchOptions, sortColumns]), { diff --git a/awx/ui/src/components/JobList/JobList.js b/awx/ui/src/components/JobList/JobList.js index 0547212d0d..1fd918ab57 100644 --- a/awx/ui/src/components/JobList/JobList.js +++ b/awx/ui/src/components/JobList/JobList.js @@ -20,6 +20,7 @@ import PaginatedTable, { HeaderRow, HeaderCell, ToolbarDeleteButton, + getSearchableKeys, } from '../PaginatedTable'; import JobListItem from './JobListItem'; import JobListCancelButton from './JobListCancelButton'; @@ -59,9 +60,7 @@ function JobList({ defaultParams, showTypeColumn = false }) { relatedSearchableKeys: ( actionsResponse?.data?.related_search_fields || [] ).map((val) => val.slice(0, -8)), - searchableKeys: Object.keys( - actionsResponse.data.actions?.GET || {} - ).filter((key) => actionsResponse.data.actions?.GET[key].filterable), + searchableKeys: getSearchableKeys(actionsResponse.data.actions?.GET), }; }, [location] // eslint-disable-line react-hooks/exhaustive-deps diff --git a/awx/ui/src/components/Lookup/HostFilterLookup.js b/awx/ui/src/components/Lookup/HostFilterLookup.js index 4b5d3a324e..3468d5d4b7 100644 --- a/awx/ui/src/components/Lookup/HostFilterLookup.js +++ b/awx/ui/src/components/Lookup/HostFilterLookup.js @@ -21,7 +21,11 @@ import ChipGroup from '../ChipGroup'; import Popover from '../Popover'; import DataListToolbar from '../DataListToolbar'; import LookupErrorMessage from './shared/LookupErrorMessage'; -import PaginatedTable, { HeaderCell, HeaderRow } from '../PaginatedTable'; +import PaginatedTable, { + HeaderCell, + HeaderRow, + getSearchableKeys, +} from '../PaginatedTable'; import HostListItem from './HostListItem'; import { removeDefaultParams, @@ -157,9 +161,7 @@ function HostFilterLookup({ relatedSearchableKeys: (actions?.related_search_fields || []).map( parseRelatedSearchFields ), - searchableKeys: Object.keys(actions?.actions.GET || {}).filter( - (key) => actions.actions?.GET[key].filterable - ), + searchableKeys: getSearchableKeys(actions?.actions.GET), }; }, [location.search] diff --git a/awx/ui/src/components/Lookup/InventoryLookup.js b/awx/ui/src/components/Lookup/InventoryLookup.js index 71a92108f4..41991a0c1d 100644 --- a/awx/ui/src/components/Lookup/InventoryLookup.js +++ b/awx/ui/src/components/Lookup/InventoryLookup.js @@ -74,14 +74,17 @@ function InventoryLookup({ relatedSearchableKeys: ( actionsResponse?.data?.related_search_fields || [] ).map((val) => val.slice(0, -8)), - searchableKeys: Object.keys( - actionsResponse.data.actions?.GET || {} - ).filter((key) => { - if (['kind', 'host_filter'].includes(key) && hideSmartInventories) { - return false; - } - return actionsResponse.data.actions?.GET[key].filterable; - }), + searchableKeys: Object.keys(actionsResponse.data.actions?.GET || {}) + .filter((key) => { + if (['kind', 'host_filter'].includes(key) && hideSmartInventories) { + return false; + } + return actionsResponse.data.actions?.GET[key].filterable; + }) + .map((key) => ({ + key, + type: actionsResponse.data.actions?.GET[key].type, + })), canEdit: Boolean(actionsResponse.data.actions.POST) || isOverrideDisabled, }; diff --git a/awx/ui/src/components/NotificationList/NotificationList.js b/awx/ui/src/components/NotificationList/NotificationList.js index 6d3a05f682..3b4171ec90 100644 --- a/awx/ui/src/components/NotificationList/NotificationList.js +++ b/awx/ui/src/components/NotificationList/NotificationList.js @@ -9,7 +9,11 @@ import { NotificationTemplatesAPI } from 'api'; import AlertModal from '../AlertModal'; import ErrorDetail from '../ErrorDetail'; import NotificationListItem from './NotificationListItem'; -import PaginatedTable, { HeaderRow, HeaderCell } from '../PaginatedTable'; +import PaginatedTable, { + HeaderRow, + HeaderCell, + getSearchableKeys, +} from '../PaginatedTable'; const QS_CONFIG = getQSConfig('notification', { page: 1, @@ -89,9 +93,7 @@ function NotificationList({ relatedSearchableKeys: ( actionsResponse?.data?.related_search_fields || [] ).map((val) => val.slice(0, -8)), - searchableKeys: Object.keys( - actionsResponse.data.actions?.GET || {} - ).filter((key) => actionsResponse.data.actions?.GET[key].filterable), + searchableKeys: getSearchableKeys(actionsResponse.data.actions?.GET), }; if (showApprovalsToggle) { diff --git a/awx/ui/src/components/PaginatedTable/getSearchableKeys.js b/awx/ui/src/components/PaginatedTable/getSearchableKeys.js new file mode 100644 index 0000000000..ed9fe0fe0c --- /dev/null +++ b/awx/ui/src/components/PaginatedTable/getSearchableKeys.js @@ -0,0 +1,8 @@ +export default function getSearchableKeys(keys = {}) { + return Object.keys(keys) + .filter((key) => keys[key].filterable) + .map((key) => ({ + key, + type: keys[key].type, + })); +} diff --git a/awx/ui/src/components/PaginatedTable/index.js b/awx/ui/src/components/PaginatedTable/index.js index e30c1e1711..67b83c87c2 100644 --- a/awx/ui/src/components/PaginatedTable/index.js +++ b/awx/ui/src/components/PaginatedTable/index.js @@ -5,3 +5,4 @@ export { default as ActionItem } from './ActionItem'; export { default as ToolbarDeleteButton } from './ToolbarDeleteButton'; export { default as ToolbarAddButton } from './ToolbarAddButton'; export { default as ToolbarSyncSourceButton } from './ToolbarSyncSourceButton'; +export { default as getSearchableKeys } from './getSearchableKeys'; diff --git a/awx/ui/src/components/ResourceAccessList/ResourceAccessList.js b/awx/ui/src/components/ResourceAccessList/ResourceAccessList.js index c8b0254386..e4892e0371 100644 --- a/awx/ui/src/components/ResourceAccessList/ResourceAccessList.js +++ b/awx/ui/src/components/ResourceAccessList/ResourceAccessList.js @@ -11,6 +11,7 @@ import PaginatedTable, { HeaderRow, HeaderCell, ToolbarAddButton, + getSearchableKeys, } from '../PaginatedTable'; import DeleteRoleConfirmationModal from './DeleteRoleConfirmationModal'; import ResourceAccessListItem from './ResourceAccessListItem'; @@ -89,9 +90,7 @@ function ResourceAccessList({ apiModel, resource }) { relatedSearchableKeys: ( actionsResponse?.data?.related_search_fields || [] ).map((val) => val.slice(0, -8)), - searchableKeys: Object.keys( - actionsResponse.data.actions?.GET || {} - ).filter((key) => actionsResponse.data.actions?.GET[key].filterable), + searchableKeys: getSearchableKeys(actionsResponse.data.actions?.GET), organizationRoles: orgRoles, }; }, [apiModel, location, resource]), diff --git a/awx/ui/src/components/Schedule/ScheduleList/ScheduleList.js b/awx/ui/src/components/Schedule/ScheduleList/ScheduleList.js index 97b7e4ec3b..d74d9f64f7 100644 --- a/awx/ui/src/components/Schedule/ScheduleList/ScheduleList.js +++ b/awx/ui/src/components/Schedule/ScheduleList/ScheduleList.js @@ -14,6 +14,7 @@ import PaginatedTable, { HeaderCell, ToolbarAddButton, ToolbarDeleteButton, + getSearchableKeys, } from '../../PaginatedTable'; import DataListToolbar from '../../DataListToolbar'; import ScheduleListItem from './ScheduleListItem'; @@ -61,9 +62,7 @@ function ScheduleList({ relatedSearchableKeys: ( scheduleActions?.data?.related_search_fields || [] ).map((val) => val.slice(0, -8)), - searchableKeys: Object.keys( - scheduleActions.data.actions?.GET || {} - ).filter((key) => scheduleActions.data.actions?.GET[key].filterable), + searchableKeys: getSearchableKeys(scheduleActions.data.actions?.GET), }; }, [location.search, loadSchedules, loadScheduleOptions]), { diff --git a/awx/ui_next/src/components/Search/LookupTypeInput.js b/awx/ui/src/components/Search/LookupTypeInput.js similarity index 97% rename from awx/ui_next/src/components/Search/LookupTypeInput.js rename to awx/ui/src/components/Search/LookupTypeInput.js index b14af41703..bb5eea7106 100644 --- a/awx/ui_next/src/components/Search/LookupTypeInput.js +++ b/awx/ui/src/components/Search/LookupTypeInput.js @@ -104,24 +104,28 @@ function LookupTypeInput({ value, type, setValue, maxSelectHeight }) { key="gt" value="gt" description={t`Greater than comparison.`} + show={type !== 'json'} />