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
This commit is contained in:
nixocio 2020-08-24 21:23:22 -04:00
parent 1a033653ae
commit de130eb798
2 changed files with 34 additions and 2 deletions

View File

@ -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 => (
<DatalistToolbar
{...props}

View File

@ -49,7 +49,13 @@ function InstanceGroupList({ i18n }) {
error: contentError,
isLoading,
request: fetchInstanceGroups,
result: { instanceGroups, instanceGroupsCount, actions },
result: {
instanceGroups,
instanceGroupsCount,
actions,
relatedSearchableKeys,
searchableKeys,
},
} = useRequest(
useCallback(async () => {
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 => (
<DatalistToolbar
{...props}