mirror of
https://github.com/ansible/awx.git
synced 2026-05-24 00:57:48 -02:30
Configure advanced search on notification templates list
This commit is contained in:
@@ -29,27 +29,41 @@ function NotificationTemplatesList({ i18n }) {
|
|||||||
const addUrl = `${match.url}/add`;
|
const addUrl = `${match.url}/add`;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
result: { templates, count, actions },
|
result: {
|
||||||
|
templates,
|
||||||
|
count,
|
||||||
|
actions,
|
||||||
|
relatedSearchableKeys,
|
||||||
|
searchableKeys,
|
||||||
|
},
|
||||||
error: contentError,
|
error: contentError,
|
||||||
isLoading: isTemplatesLoading,
|
isLoading: isTemplatesLoading,
|
||||||
request: fetchTemplates,
|
request: fetchTemplates,
|
||||||
} = useRequest(
|
} = useRequest(
|
||||||
useCallback(async () => {
|
useCallback(async () => {
|
||||||
const params = parseQueryString(QS_CONFIG, location.search);
|
const params = parseQueryString(QS_CONFIG, location.search);
|
||||||
const responses = await Promise.all([
|
const [response, actionsResponse] = await Promise.all([
|
||||||
NotificationTemplatesAPI.read(params),
|
NotificationTemplatesAPI.read(params),
|
||||||
NotificationTemplatesAPI.readOptions(),
|
NotificationTemplatesAPI.readOptions(),
|
||||||
]);
|
]);
|
||||||
return {
|
return {
|
||||||
templates: responses[0].data.results,
|
templates: response.data.results,
|
||||||
count: responses[0].data.count,
|
count: response.data.count,
|
||||||
actions: responses[1].data.actions,
|
actions: actionsResponse.data.actions,
|
||||||
|
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),
|
||||||
};
|
};
|
||||||
}, [location]),
|
}, [location]),
|
||||||
{
|
{
|
||||||
templates: [],
|
templates: [],
|
||||||
count: 0,
|
count: 0,
|
||||||
actions: {},
|
actions: {},
|
||||||
|
relatedSearchableKeys: [],
|
||||||
|
searchableKeys: [],
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -133,6 +147,8 @@ function NotificationTemplatesList({ i18n }) {
|
|||||||
key: 'modified_by__username__icontains',
|
key: 'modified_by__username__icontains',
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
toolbarSearchableKeys={searchableKeys}
|
||||||
|
toolbarRelatedSearchableKeys={relatedSearchableKeys}
|
||||||
toolbarSortColumns={[
|
toolbarSortColumns={[
|
||||||
{
|
{
|
||||||
name: i18n._(t`Name`),
|
name: i18n._(t`Name`),
|
||||||
|
|||||||
Reference in New Issue
Block a user