From de130eb79820358e57d6c87095a6d30bb929caa3 Mon Sep 17 00:00:00 2001 From: nixocio Date: Mon, 24 Aug 2020 21:23:22 -0400 Subject: [PATCH] Add advanced search keys for InstanceGroup and CredentialType Lists Add advanced search keys for `InstanceGroup` and `CredentialType` Lists. See: https://github.com/ansible/awx/pull/7895/files --- .../CredentialTypeList/CredentialTypeList.jsx | 18 +++++++++++++++++- .../InstanceGroupList/InstanceGroupList.jsx | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/awx/ui_next/src/screens/CredentialType/CredentialTypeList/CredentialTypeList.jsx b/awx/ui_next/src/screens/CredentialType/CredentialTypeList/CredentialTypeList.jsx index 4051adee05..b212f0b76e 100644 --- a/awx/ui_next/src/screens/CredentialType/CredentialTypeList/CredentialTypeList.jsx +++ b/awx/ui_next/src/screens/CredentialType/CredentialTypeList/CredentialTypeList.jsx @@ -32,7 +32,13 @@ function CredentialTypeList({ i18n }) { error: contentError, isLoading, request: fetchCredentialTypes, - result: { credentialTypes, credentialTypesCount, actions }, + result: { + credentialTypes, + credentialTypesCount, + actions, + relatedSearchableKeys, + searchableKeys, + }, } = useRequest( useCallback(async () => { const params = parseQueryString(QS_CONFIG, location.search); @@ -46,12 +52,20 @@ function CredentialTypeList({ i18n }) { credentialTypes: response.data.results, credentialTypesCount: response.data.count, actions: responseActions.data.actions, + relatedSearchableKeys: ( + responseActions?.data?.related_search_fields || [] + ).map(val => val.slice(0, -8)), + searchableKeys: Object.keys( + responseActions.data.actions?.GET || {} + ).filter(key => responseActions.data.actions?.GET[key].filterable), }; }, [location]), { credentialTypes: [], credentialTypesCount: 0, actions: {}, + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -100,6 +114,8 @@ function CredentialTypeList({ i18n }) { pluralizedItemName={i18n._(t`Credential Types`)} qsConfig={QS_CONFIG} onRowClick={handleSelect} + toolbarSearchableKeys={searchableKeys} + toolbarRelatedSearchableKeys={relatedSearchableKeys} renderToolbar={props => ( { const params = parseQueryString(QS_CONFIG, location.search); @@ -63,12 +69,20 @@ function InstanceGroupList({ i18n }) { instanceGroups: response.data.results, instanceGroupsCount: response.data.count, actions: responseActions.data.actions, + relatedSearchableKeys: ( + responseActions?.data?.related_search_fields || [] + ).map(val => val.slice(0, -8)), + searchableKeys: Object.keys( + responseActions.data.actions?.GET || {} + ).filter(key => responseActions.data.actions?.GET[key].filterable), }; }, [location]), { instanceGroups: [], instanceGroupsCount: 0, actions: {}, + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -171,6 +185,8 @@ function InstanceGroupList({ i18n }) { pluralizedItemName={pluralizedItemName} qsConfig={QS_CONFIG} onRowClick={handleSelect} + toolbarSearchableKeys={searchableKeys} + toolbarRelatedSearchableKeys={relatedSearchableKeys} renderToolbar={props => (