diff --git a/awx/ui_next/src/components/JobList/JobList.jsx b/awx/ui_next/src/components/JobList/JobList.jsx index b1108b8cb9fb..502b4378c713 100644 --- a/awx/ui_next/src/components/JobList/JobList.jsx +++ b/awx/ui_next/src/components/JobList/JobList.jsx @@ -38,7 +38,7 @@ function JobList({ i18n, defaultParams, showTypeColumn = false }) { const [selected, setSelected] = useState([]); const location = useLocation(); const { - result: { results, count, actions, relatedSearchFields }, + result: { results, count, relatedSearchableKeys, searchableKeys }, error: contentError, isLoading, request: fetchJobs, @@ -53,10 +53,12 @@ function JobList({ i18n, defaultParams, showTypeColumn = false }) { return { results: response.data.results, count: response.data.count, - actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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] // eslint-disable-line react-hooks/exhaustive-deps @@ -64,8 +66,8 @@ function JobList({ i18n, defaultParams, showTypeColumn = false }) { { results: [], count: 0, - actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); useEffect(() => { @@ -138,11 +140,6 @@ function JobList({ i18n, defaultParams, showTypeColumn = false }) { } }; - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - return ( <> diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/CredentialsStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/CredentialsStep.jsx index 357b9472db36..1b736c6ad083 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/CredentialsStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/CredentialsStep.jsx @@ -52,7 +52,7 @@ function CredentialsStep({ i18n }) { }, [fetchTypes]); const { - result: { credentials, count, actions, relatedSearchFields }, + result: { credentials, count, relatedSearchableKeys, searchableKeys }, error: credentialsError, isLoading: isCredentialsLoading, request: fetchCredentials, @@ -72,13 +72,15 @@ function CredentialsStep({ i18n }) { return { credentials: data.results, count: data.count, - actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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), }; }, [selectedType, history.location.search]), - { credentials: [], count: 0, actions: {}, relatedSearchFields: [] } + { credentials: [], count: 0, relatedSearchableKeys: [], searchableKeys: [] } ); useEffect(() => { @@ -104,11 +106,6 @@ function CredentialsStep({ i18n }) { /> ); - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - return ( <> {types && types.length > 0 && ( diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx index 0c23c0c2b279..e7026c66b728 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx @@ -27,7 +27,7 @@ function InventoryStep({ i18n }) { const { isLoading, error, - result: { inventories, count, actions, relatedSearchFields }, + result: { inventories, count, relatedSearchableKeys, searchableKeys }, request: fetchInventories, } = useRequest( useCallback(async () => { @@ -39,17 +39,19 @@ function InventoryStep({ i18n }) { return { inventories: data.results, count: data.count, - actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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), }; }, [history.location]), { count: 0, inventories: [], - actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -57,11 +59,6 @@ function InventoryStep({ i18n }) { fetchInventories(); }, [fetchInventories]); - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - if (isLoading) { return ; } diff --git a/awx/ui_next/src/components/Lookup/ApplicationLookup.jsx b/awx/ui_next/src/components/Lookup/ApplicationLookup.jsx index 8056114046df..01fd154c4710 100644 --- a/awx/ui_next/src/components/Lookup/ApplicationLookup.jsx +++ b/awx/ui_next/src/components/Lookup/ApplicationLookup.jsx @@ -22,7 +22,7 @@ function ApplicationLookup({ i18n, onChange, value, label }) { const location = useLocation(); const { error, - result: { applications, itemCount, actions, relatedSearchFields }, + result: { applications, itemCount, relatedSearchableKeys, searchableKeys }, request: fetchApplications, } = useRequest( useCallback(async () => { @@ -40,23 +40,24 @@ function ApplicationLookup({ i18n, onChange, value, label }) { return { applications: results, itemCount: count, - actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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]), - { applications: [], itemCount: 0, actions: {}, relatedSearchFields: [] } + { + applications: [], + itemCount: 0, + relatedSearchableKeys: [], + searchableKeys: [], + } ); useEffect(() => { fetchApplications(); }, [fetchApplications]); - - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - return ( val.slice(0, -8)), + searchableKeys: Object.keys( + actionsResponse.data.actions?.GET || {} + ).filter(key => actionsResponse.data.actions?.GET[key].filterable), }; }, [ credentialTypeId, @@ -78,8 +80,8 @@ function CredentialLookup({ { count: 0, credentials: [], - actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -87,11 +89,6 @@ function CredentialLookup({ fetchCredentials(); }, [fetchCredentials]); - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - // TODO: replace credential type search with REST-based grabbing of cred types return ( diff --git a/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx b/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx index 21fe8cfa8f51..49c257cb6a6f 100644 --- a/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx +++ b/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx @@ -30,7 +30,7 @@ function InstanceGroupsLookup(props) { } = props; const { - result: { instanceGroups, count, actions, relatedSearchFields }, + result: { instanceGroups, count, relatedSearchableKeys, searchableKeys }, request: fetchInstanceGroups, error, isLoading, @@ -44,24 +44,26 @@ function InstanceGroupsLookup(props) { return { instanceGroups: data.results, count: data.count, - actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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), }; }, [history.location]), - { instanceGroups: [], count: 0, actions: {}, relatedSearchFields: [] } + { + instanceGroups: [], + count: 0, + relatedSearchableKeys: [], + searchableKeys: [], + } ); useEffect(() => { fetchInstanceGroups(); }, [fetchInstanceGroups]); - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - return ( val.slice(0, -8)), + searchableKeys: Object.keys( + actionsResponse.data.actions?.GET || {} + ).filter(key => actionsResponse.data.actions?.GET[key].filterable), }; }, [history.location]), - { inventories: [], count: 0, actions: {}, relatedSearchFields: [] } + { inventories: [], count: 0, relatedSearchableKeys: [], searchableKeys: [] } ); useEffect(() => { fetchInventories(); }, [fetchInventories]); - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - return ( <> val.slice(0, -8)), + searchableKeys: Object.keys( + actionsResponse.data.actions?.GET || {} + ).filter(key => actionsResponse.data.actions?.GET[key].filterable), }; }, [selectedType, history.location]), { credentials: [], credentialsCount: 0, - actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -104,11 +111,6 @@ function MultiCredentialsLookup(props) { const isVault = selectedType?.kind === 'vault'; - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - return ( val.slice(0, -8)), + searchableKeys: Object.keys( + actionsResponse.data.actions?.GET || {} + ).filter(key => actionsResponse.data.actions?.GET[key].filterable), }; }, [history.location.search, autocomplete]), { count: 0, projects: [], - actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -67,11 +69,6 @@ function ProjectLookup({ fetchProjects(); }, [fetchProjects]); - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - return ( val.slice(0, -8)), + searchableKeys: Object.keys( + scheduleActions.data.actions?.GET || {} + ).filter(key => scheduleActions.data.actions?.GET[key].filterable), }; }, [location, loadSchedules, loadScheduleOptions]), { schedules: [], itemCount: 0, actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -106,10 +116,6 @@ function ScheduleList({ actions && Object.prototype.hasOwnProperty.call(actions, 'POST') && !hideAddButton; - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); return ( <> diff --git a/awx/ui_next/src/screens/Application/ApplicationTokens/ApplicationTokenList.jsx b/awx/ui_next/src/screens/Application/ApplicationTokens/ApplicationTokenList.jsx index 7d123385ef02..2ad56eaa7f26 100644 --- a/awx/ui_next/src/screens/Application/ApplicationTokens/ApplicationTokenList.jsx +++ b/awx/ui_next/src/screens/Application/ApplicationTokens/ApplicationTokenList.jsx @@ -26,7 +26,7 @@ function ApplicationTokenList({ i18n }) { const { error, isLoading, - result: { tokens, itemCount, actions, relatedSearchFields }, + result: { tokens, itemCount, relatedSearchableKeys, searchableKeys }, request: fetchTokens, } = useRequest( useCallback(async () => { @@ -52,13 +52,15 @@ function ApplicationTokenList({ i18n }) { return { tokens: modifiedResults, itemCount: count, - actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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), }; }, [id, location.search]), - { tokens: [], itemCount: 0, actions: {}, relatedSearchFields: [] } + { tokens: [], itemCount: 0, relatedSearchableKeys: [], searchableKeys: [] } ); useEffect(() => { @@ -91,11 +93,6 @@ function ApplicationTokenList({ i18n }) { setSelected([]); }; - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - return ( <> { const params = parseQueryString(QS_CONFIG, location.search); @@ -46,16 +52,20 @@ function ApplicationsList({ i18n }) { applications: response.data.results, itemCount: response.data.count, actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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]), { applications: [], itemCount: 0, actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -89,10 +99,6 @@ function ApplicationsList({ i18n }) { }; const canAdd = actions && actions.POST; - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); return ( <> diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialPlugins/CredentialPluginPrompt/CredentialsStep.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialPlugins/CredentialPluginPrompt/CredentialsStep.jsx index 40a305e72f31..bc91a9889442 100644 --- a/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialPlugins/CredentialPluginPrompt/CredentialsStep.jsx +++ b/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialPlugins/CredentialPluginPrompt/CredentialsStep.jsx @@ -25,7 +25,7 @@ function CredentialsStep({ i18n }) { const history = useHistory(); const { - result: { credentials, count, actions, relatedSearchFields }, + result: { credentials, count, relatedSearchableKeys, searchableKeys }, error: credentialsError, isLoading: isCredentialsLoading, request: fetchCredentials, @@ -39,24 +39,21 @@ function CredentialsStep({ i18n }) { return { credentials: data.results, count: data.count, - actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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), }; }, [history.location.search]), - { credentials: [], count: 0, actions: {}, relatedSearchFields: [] } + { credentials: [], count: 0, relatedSearchableKeys: [], searchableKeys: [] } ); useEffect(() => { fetchCredentials(); }, [fetchCredentials]); - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - if (credentialsError) { return ; } diff --git a/awx/ui_next/src/screens/Host/HostGroups/HostGroupsList.jsx b/awx/ui_next/src/screens/Host/HostGroups/HostGroupsList.jsx index bfcde651a4d3..6233df73bf21 100644 --- a/awx/ui_next/src/screens/Host/HostGroups/HostGroupsList.jsx +++ b/awx/ui_next/src/screens/Host/HostGroups/HostGroupsList.jsx @@ -33,7 +33,13 @@ function HostGroupsList({ i18n, host }) { const invId = host.summary_fields.inventory.id; const { - result: { groups, itemCount, actions, relatedSearchFields }, + result: { + groups, + itemCount, + actions, + relatedSearchableKeys, + searchableKeys, + }, error: contentError, isLoading, request: fetchGroups, @@ -55,16 +61,20 @@ function HostGroupsList({ i18n, host }) { groups: results, itemCount: count, actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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), }; }, [hostId, search]), { groups: [], itemCount: 0, actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -128,10 +138,6 @@ function HostGroupsList({ i18n, host }) { const canAdd = actions && Object.prototype.hasOwnProperty.call(actions, 'POST'); - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); return ( <> diff --git a/awx/ui_next/src/screens/Host/HostList/HostList.jsx b/awx/ui_next/src/screens/Host/HostList/HostList.jsx index 3e6a2589c666..a11ec3f4d127 100644 --- a/awx/ui_next/src/screens/Host/HostList/HostList.jsx +++ b/awx/ui_next/src/screens/Host/HostList/HostList.jsx @@ -29,7 +29,7 @@ function HostList({ i18n }) { const [selected, setSelected] = useState([]); const { - result: { hosts, count, actions, relatedSearchFields }, + result: { hosts, count, actions, relatedSearchableKeys, searchableKeys }, error: contentError, isLoading, request: fetchHosts, @@ -44,16 +44,20 @@ function HostList({ i18n }) { hosts: results[0].data.results, count: results[0].data.count, actions: results[1].data.actions, - relatedSearchFields: ( + relatedSearchableKeys: ( results[1]?.data?.related_search_fields || [] ).map(val => val.slice(0, -8)), + searchableKeys: Object.keys(results[1].data.actions?.GET || {}).filter( + key => results[1].data.actions?.GET[key].filterable + ), }; }, [location]), { hosts: [], count: 0, actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -97,10 +101,6 @@ function HostList({ i18n }) { const canAdd = actions && Object.prototype.hasOwnProperty.call(actions, 'POST'); - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); return ( diff --git a/awx/ui_next/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostList.jsx b/awx/ui_next/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostList.jsx index 17fc055997ce..8584c0120738 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostList.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostList.jsx @@ -32,7 +32,13 @@ function InventoryGroupHostList({ i18n }) { const history = useHistory(); const { - result: { hosts, hostCount, actions, relatedSearchFields }, + result: { + hosts, + hostCount, + actions, + relatedSearchableKeys, + searchableKeys, + }, error: contentError, isLoading, request: fetchHosts, @@ -48,16 +54,20 @@ function InventoryGroupHostList({ i18n }) { hosts: response.data.results, hostCount: response.data.count, actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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), }; }, [groupId, inventoryId, location.search]), { hosts: [], hostCount: 0, actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -127,10 +137,6 @@ function InventoryGroupHostList({ i18n }) { const canAdd = actions && Object.prototype.hasOwnProperty.call(actions, 'POST'); const addFormUrl = `/inventories/inventory/${inventoryId}/groups/${groupId}/nested_hosts/add`; - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); return ( <> diff --git a/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupsList.jsx b/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupsList.jsx index 4b741896029f..2f8d8fa1eac4 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupsList.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupsList.jsx @@ -31,7 +31,13 @@ function InventoryHostGroupsList({ i18n }) { const { search } = useLocation(); const { - result: { groups, itemCount, actions, relatedSearchFields }, + result: { + groups, + itemCount, + actions, + relatedSearchableKeys, + searchableKeys, + }, error: contentError, isLoading, request: fetchGroups, @@ -53,16 +59,20 @@ function InventoryHostGroupsList({ i18n }) { groups: results, itemCount: count, actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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), }; }, [hostId, search]), // eslint-disable-line react-hooks/exhaustive-deps { groups: [], itemCount: 0, actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -126,10 +136,6 @@ function InventoryHostGroupsList({ i18n }) { const canAdd = actions && Object.prototype.hasOwnProperty.call(actions, 'POST'); - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); return ( <> diff --git a/awx/ui_next/src/screens/Inventory/InventoryList/InventoryList.jsx b/awx/ui_next/src/screens/Inventory/InventoryList/InventoryList.jsx index 94f22e70a396..e5ff1f6dd44d 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryList/InventoryList.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryList/InventoryList.jsx @@ -29,7 +29,13 @@ function InventoryList({ i18n }) { const [selected, setSelected] = useState([]); const { - result: { results, itemCount, actions, relatedSearchFields }, + result: { + results, + itemCount, + actions, + relatedSearchableKeys, + searchableKeys, + }, error: contentError, isLoading, request: fetchInventories, @@ -44,16 +50,20 @@ function InventoryList({ i18n }) { results: response.data.results, itemCount: response.data.count, actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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]), { results: [], itemCount: 0, actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -97,10 +107,6 @@ function InventoryList({ i18n }) { const hasContentLoading = isDeleteLoading || isLoading; const canAdd = actions && actions.POST; - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); const handleSelectAll = isSelected => { setSelected(isSelected ? [...inventories] : []); diff --git a/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx b/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx index 152004ae5cc4..7b3c0eeda2e2 100644 --- a/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx +++ b/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx @@ -31,7 +31,13 @@ function OrganizationsList({ i18n }) { const addUrl = `${match.url}/add`; const { - result: { organizations, organizationCount, actions, relatedSearchFields }, + result: { + organizations, + organizationCount, + actions, + relatedSearchableKeys, + searchableKeys, + }, error: contentError, isLoading: isOrgsLoading, request: fetchOrganizations, @@ -46,16 +52,20 @@ function OrganizationsList({ i18n }) { organizations: orgs.data.results, organizationCount: orgs.data.count, actions: orgActions.data.actions, - relatedSearchFields: ( + relatedSearchableKeys: ( orgActions?.data?.related_search_fields || [] ).map(val => val.slice(0, -8)), + searchableKeys: Object.keys(orgActions.data.actions?.GET || {}).filter( + key => orgActions.data.actions?.GET[key].filterable + ), }; }, [location]), { organizations: [], organizationCount: 0, actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -90,10 +100,6 @@ function OrganizationsList({ i18n }) { const hasContentLoading = isDeleteLoading || isOrgsLoading; const canAdd = actions && actions.POST; - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); const handleSelectAll = isSelected => { setSelected(isSelected ? [...organizations] : []); diff --git a/awx/ui_next/src/screens/Project/ProjectList/ProjectList.jsx b/awx/ui_next/src/screens/Project/ProjectList/ProjectList.jsx index 13b3a98c2ce2..7afbe124b355 100644 --- a/awx/ui_next/src/screens/Project/ProjectList/ProjectList.jsx +++ b/awx/ui_next/src/screens/Project/ProjectList/ProjectList.jsx @@ -30,7 +30,13 @@ function ProjectList({ i18n }) { const [selected, setSelected] = useState([]); const { - result: { results, itemCount, actions, relatedSearchFields }, + result: { + results, + itemCount, + actions, + relatedSearchableKeys, + searchableKeys, + }, error: contentError, isLoading, request: fetchProjects, @@ -45,16 +51,20 @@ function ProjectList({ i18n }) { results: response.data.results, itemCount: response.data.count, actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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]), { results: [], itemCount: 0, actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -89,10 +99,6 @@ function ProjectList({ i18n }) { const hasContentLoading = isDeleteLoading || isLoading; const canAdd = actions && actions.POST; - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); const handleSelectAll = isSelected => { setSelected(isSelected ? [...projects] : []); diff --git a/awx/ui_next/src/screens/Team/TeamList/TeamList.jsx b/awx/ui_next/src/screens/Team/TeamList/TeamList.jsx index f6600642667c..07de516ca4bd 100644 --- a/awx/ui_next/src/screens/Team/TeamList/TeamList.jsx +++ b/awx/ui_next/src/screens/Team/TeamList/TeamList.jsx @@ -29,7 +29,13 @@ function TeamList({ i18n }) { const [selected, setSelected] = useState([]); const { - result: { teams, itemCount, actions, relatedSearchFields }, + result: { + teams, + itemCount, + actions, + relatedSearchableKeys, + searchableKeys, + }, error: contentError, isLoading, request: fetchTeams, @@ -44,16 +50,20 @@ function TeamList({ i18n }) { teams: response.data.results, itemCount: response.data.count, actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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]), { teams: [], itemCount: 0, actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -85,10 +95,6 @@ function TeamList({ i18n }) { const hasContentLoading = isDeleteLoading || isLoading; const canAdd = actions && actions.POST; - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); const handleSelectAll = isSelected => { setSelected(isSelected ? [...teams] : []); diff --git a/awx/ui_next/src/screens/Team/TeamRoles/TeamRolesList.jsx b/awx/ui_next/src/screens/Team/TeamRoles/TeamRolesList.jsx index 05ffce9fe1e7..31db276045de 100644 --- a/awx/ui_next/src/screens/Team/TeamRoles/TeamRolesList.jsx +++ b/awx/ui_next/src/screens/Team/TeamRoles/TeamRolesList.jsx @@ -37,7 +37,13 @@ function TeamRolesList({ i18n, me, team }) { isLoading, request: fetchRoles, contentError, - result: { roleCount, roles, isAdminOfOrg, actions, relatedSearchFields }, + result: { + roleCount, + roles, + isAdminOfOrg, + relatedSearchableKeys, + searchableKeys, + }, } = useRequest( useCallback(async () => { const params = parseQueryString(QS_CONFIG, search); @@ -58,18 +64,20 @@ function TeamRolesList({ i18n, me, team }) { roleCount: count, roles: results, isAdminOfOrg: orgAdminCount > 0, - actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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), }; }, [me.id, team.id, team.organization, search]), { roles: [], roleCount: 0, isAdminOfOrg: false, - actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -98,11 +106,6 @@ function TeamRolesList({ i18n, me, team }) { ); const canAdd = team?.summary_fields?.user_capabilities?.edit || isAdminOfOrg; - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - const detailUrl = role => { const { resource_id, resource_type } = role.summary_fields; diff --git a/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx b/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx index 31c04263ade8..455bf4ce6c3e 100644 --- a/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx +++ b/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx @@ -36,7 +36,14 @@ function TemplateList({ i18n }) { const [selected, setSelected] = useState([]); const { - result: { results, count, jtActions, wfjtActions, relatedSearchFields }, + result: { + results, + count, + jtActions, + wfjtActions, + relatedSearchableKeys, + searchableKeys, + }, error: contentError, isLoading, request: fetchTemplates, @@ -47,20 +54,19 @@ function TemplateList({ i18n }) { UnifiedJobTemplatesAPI.read(params), JobTemplatesAPI.readOptions(), WorkflowJobTemplatesAPI.readOptions(), + UnifiedJobTemplatesAPI.readOptions(), ]); return { results: responses[0].data.results, count: responses[0].data.count, jtActions: responses[1].data.actions, wfjtActions: responses[2].data.actions, - relatedSearchFields: [ - ...(responses[1]?.data?.related_search_fields || []).map(val => - val.slice(0, -8) - ), - ...(responses[2]?.data?.related_search_fields || []).map(val => - val.slice(0, -8) - ), - ], + relatedSearchableKeys: ( + responses[3]?.data?.related_search_fields || [] + ).map(val => val.slice(0, -8)), + searchableKeys: Object.keys( + responses[3].data.actions?.GET || {} + ).filter(key => responses[3].data.actions?.GET[key].filterable), }; }, [location]), { @@ -68,7 +74,8 @@ function TemplateList({ i18n }) { count: 0, jtActions: {}, wfjtActions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -128,17 +135,6 @@ function TemplateList({ i18n }) { const canAddWFJT = wfjtActions && Object.prototype.hasOwnProperty.call(wfjtActions, 'POST'); // spreading Set() returns only unique keys - const relatedSearchableKeys = [...new Set(relatedSearchFields)] || []; - const searchableKeys = [ - ...new Set([ - ...Object.keys(jtActions?.GET || {}).filter( - key => jtActions.GET[key].filterable - ), - ...Object.keys(wfjtActions?.GET || {}).filter( - key => wfjtActions.GET[key].filterable - ), - ]), - ]; const addButtonOptions = []; if (canAddJT) { diff --git a/awx/ui_next/src/screens/User/UserAccess/UserAccessList.jsx b/awx/ui_next/src/screens/User/UserAccess/UserAccessList.jsx index 4d9ff7a67101..5e528913c172 100644 --- a/awx/ui_next/src/screens/User/UserAccess/UserAccessList.jsx +++ b/awx/ui_next/src/screens/User/UserAccess/UserAccessList.jsx @@ -38,7 +38,13 @@ function UserAccessList({ i18n, user }) { isLoading, request: fetchRoles, error, - result: { roleCount, roles, actions, relatedSearchFields }, + result: { + roleCount, + roles, + actions, + relatedSearchableKeys, + searchableKeys, + }, } = useRequest( useCallback(async () => { const params = parseQueryString(QS_CONFIG, search); @@ -55,16 +61,20 @@ function UserAccessList({ i18n, user }) { roleCount: count, roles: results, actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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), }; }, [user.id, search]), { roles: [], roleCount: 0, actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -92,11 +102,6 @@ function UserAccessList({ i18n, user }) { user?.summary_fields?.user_capabilities?.edit || (actions && Object.prototype.hasOwnProperty.call(actions, 'POST')); - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - const saveRoles = () => { setIsWizardOpen(false); fetchRoles(); diff --git a/awx/ui_next/src/screens/User/UserTeams/UserTeamList.jsx b/awx/ui_next/src/screens/User/UserTeams/UserTeamList.jsx index 25d245cffd74..868cbb9e55dc 100644 --- a/awx/ui_next/src/screens/User/UserTeams/UserTeamList.jsx +++ b/awx/ui_next/src/screens/User/UserTeams/UserTeamList.jsx @@ -20,7 +20,7 @@ function UserTeamList({ i18n }) { const { id: userId } = useParams(); const { - result: { teams, count, actions, relatedSearchFields }, + result: { teams, count, relatedSearchableKeys, searchableKeys }, error: contentError, isLoading, request: fetchOrgs, @@ -39,17 +39,19 @@ function UserTeamList({ i18n }) { return { teams: results, count: teamCount, - actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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), }; }, [userId, location.search]), { teams: [], count: 0, - actions: {}, - relatedSearchFields: [], + relatedSearchableKeys: [], + searchableKeys: [], } ); @@ -57,11 +59,6 @@ function UserTeamList({ i18n }) { fetchOrgs(); }, [fetchOrgs]); - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); - return ( { const params = parseQueryString(QS_CONFIG, location.search); @@ -53,13 +53,15 @@ function UserTokenList({ i18n }) { return { tokens: modifiedResults, itemCount: count, - actions: actionsResponse.data.actions, - relatedSearchFields: ( + 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), }; }, [id, location.search]), - { tokens: [], itemCount: 0, actions: {}, relatedSearchFields: [] } + { tokens: [], itemCount: 0, relatedSearchableKeys: [], searchableKeys: [] } ); useEffect(() => { @@ -93,10 +95,7 @@ function UserTokenList({ i18n }) { }; const canAdd = true; - const relatedSearchableKeys = relatedSearchFields || []; - const searchableKeys = Object.keys(actions?.GET || {}).filter( - key => actions.GET[key].filterable - ); + return ( <>