From fa07889f39ccb7a391410780145976ca781b7886 Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Wed, 28 Oct 2020 15:41:03 -0700 Subject: [PATCH 1/5] switch host filter lookup to use icontains searches for name/group --- awx/ui_next/src/components/Lookup/HostFilterLookup.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx b/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx index e819973083..cd05b020ef 100644 --- a/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx +++ b/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx @@ -72,7 +72,7 @@ const QS_CONFIG = getQSConfig( const buildSearchColumns = i18n => [ { name: i18n._(t`Name`), - key: 'name', + key: 'name__icontains', isDefault: true, }, { @@ -81,7 +81,7 @@ const buildSearchColumns = i18n => [ }, { name: i18n._(t`Group`), - key: 'groups__name', + key: 'groups__name__icontains', }, { name: i18n._(t`Inventory ID`), From adc68b672d46a9db5535627d457c030fa77a67e2 Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Fri, 30 Oct 2020 14:45:05 -0700 Subject: [PATCH 2/5] add advanced search keys to host filter lookup --- .../src/components/Lookup/HostFilterLookup.jsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx b/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx index cd05b020ef..cefad73ce2 100644 --- a/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx +++ b/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx @@ -124,7 +124,7 @@ function HostFilterLookup({ const searchColumns = buildSearchColumns(i18n); const { - result: { count, hosts }, + result: { count, hosts, relatedSearchableKeys, searchableKeys }, error: contentError, request: fetchHosts, isLoading, @@ -135,9 +135,16 @@ function HostFilterLookup({ const { data } = await HostsAPI.read( mergeParams(params, { inventory__organization: orgId }) ); + const { data: actions } = await HostsAPI.readOptions(); return { count: data.count, hosts: data.results, + relatedSearchableKeys: ( + actions?.related_search_fields || [] + ).map(val => val.slice(0, -8)), + searchableKeys: Object.keys(actions?.actions.GET || {}).filter( + key => actions.actions?.GET[key].filterable + ), }; }, [location.search] @@ -145,6 +152,8 @@ function HostFilterLookup({ { count: 0, hosts: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -316,6 +325,8 @@ function HostFilterLookup({ key: 'modified', }, ]} + toolbarSearchableKeys={searchableKeys} + toolbarRelatedSearchableKeys={relatedSearchableKeys} /> From c58c7e285c3708b0bb14d7eac9f033fbe3b7309d Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Fri, 30 Oct 2020 14:48:02 -0700 Subject: [PATCH 3/5] use Promise.all to make requests in parallel --- awx/ui_next/src/components/Lookup/HostFilterLookup.jsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx b/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx index cefad73ce2..f8f7d56d84 100644 --- a/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx +++ b/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx @@ -132,10 +132,12 @@ function HostFilterLookup({ useCallback( async orgId => { const params = parseQueryString(QS_CONFIG, location.search); - const { data } = await HostsAPI.read( - mergeParams(params, { inventory__organization: orgId }) - ); - const { data: actions } = await HostsAPI.readOptions(); + const [{ data }, { data: actions }] = await Promise.all([ + HostsAPI.read( + mergeParams(params, { inventory__organization: orgId }) + ), + HostsAPI.readOptions(), + ]); return { count: data.count, hosts: data.results, From 8df6dc0ca011f5aabce4760ae68c8e2f8625a7ae Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Mon, 2 Nov 2020 11:24:01 -0800 Subject: [PATCH 4/5] fix SmartInventoryForm chips --- awx/ui_next/src/components/Lookup/HostFilterLookup.jsx | 2 +- .../src/screens/Inventory/shared/SmartInventoryForm.test.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx b/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx index f8f7d56d84..13a89512ea 100644 --- a/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx +++ b/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx @@ -196,7 +196,7 @@ function HostFilterLookup({ function buildChips(filter = {}) { const inputGroupChips = Object.keys(filter).reduce((obj, param) => { - const parsedKey = param.replace('__icontains', '').replace('or__', ''); + const parsedKey = param.replace('or__', ''); const chipsArray = []; if (Array.isArray(filter[param])) { diff --git a/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.test.jsx b/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.test.jsx index 34d7fb72c7..3f26decf00 100644 --- a/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.test.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.test.jsx @@ -26,7 +26,7 @@ const mockFormValues = { description: '', organization: { id: 1, name: 'mock organization' }, host_filter: - 'name__icontains=mock and name__icontains=foo and groups__name=mock group', + 'name__icontains=mock and name__icontains=foo and groups__name__icontains=mock group', instance_groups: [{ id: 123 }], variables: '---', }; From 8d87d9e6e7c4086975c537e4bf5c6a104ca43909 Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Wed, 4 Nov 2020 15:36:40 -0800 Subject: [PATCH 5/5] mark Clear filters button for translation --- awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx b/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx index f5137d905b..b1fed9d725 100644 --- a/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx +++ b/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx @@ -62,6 +62,7 @@ function DataListToolbar({ id={`${qsConfig.namespace}-list-toolbar`} clearAllFilters={clearAllFilters} collapseListedFiltersBreakpoint="lg" + clearFiltersButtonText={i18n._(t`Clear all filters`)} > {showSelectAll && (