diff --git a/awx/ui/src/components/AdHocCommands/AdHocCommands.js b/awx/ui/src/components/AdHocCommands/AdHocCommands.js index 7ddee926bf..5dd69d91a3 100644 --- a/awx/ui/src/components/AdHocCommands/AdHocCommands.js +++ b/awx/ui/src/components/AdHocCommands/AdHocCommands.js @@ -59,6 +59,7 @@ function AdHocCommands({ useEffect(() => { fetchData(); }, [fetchData]); + const { isLoading: isLaunchLoading, error: launchError, @@ -172,6 +173,8 @@ function AdHocCommands({ AdHocCommands.propTypes = { adHocItems: PropTypes.arrayOf(PropTypes.object).isRequired, hasListItems: PropTypes.bool.isRequired, + onLaunchLoading: PropTypes.func.isRequired, + moduleOptions: PropTypes.arrayOf(PropTypes.array).isRequired, }; export default AdHocCommands; diff --git a/awx/ui/src/components/AdHocCommands/AdHocCommands.test.js b/awx/ui/src/components/AdHocCommands/AdHocCommands.test.js index 25eb74ffbc..6e51fb3522 100644 --- a/awx/ui/src/components/AdHocCommands/AdHocCommands.test.js +++ b/awx/ui/src/components/AdHocCommands/AdHocCommands.test.js @@ -73,6 +73,10 @@ describe('', () => { adHocItems={adHocItems} hasListItems onLaunchLoading={() => jest.fn()} + moduleOptions={[ + ['command', 'command'], + ['shell', 'shell'], + ]} /> ); }); diff --git a/awx/ui/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostList.js b/awx/ui/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostList.js index 2a611891ae..747e7bd058 100644 --- a/awx/ui/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostList.js +++ b/awx/ui/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostList.js @@ -25,25 +25,33 @@ function SmartInventoryHostList({ inventory }) { const location = useLocation(); const [isAdHocLaunchLoading, setIsAdHocLaunchLoading] = useState(false); const { - result: { hosts, count }, + result: { hosts, count, moduleOptions }, error: contentError, isLoading, request: fetchHosts, } = useRequest( useCallback(async () => { const params = parseQueryString(QS_CONFIG, location.search); - const { - data: { results, count: hostCount }, - } = await InventoriesAPI.readHosts(inventory.id, params); + const [ + { + data: { results, count: hostCount }, + }, + adHocOptions, + ] = await Promise.all([ + InventoriesAPI.readHosts(inventory.id, params), + InventoriesAPI.readAdHocOptions(inventory.id), + ]); return { hosts: results, count: hostCount, + moduleOptions: adHocOptions.data.actions.GET.module_name.choices, }; }, [location.search, inventory.id]), { hosts: [], count: 0, + moduleOptions: [], } ); @@ -91,6 +99,7 @@ function SmartInventoryHostList({ inventory }) { adHocItems={selected} hasListItems={count > 0} onLaunchLoading={setIsAdHocLaunchLoading} + moduleOptions={moduleOptions} />, ] : [] diff --git a/awx/ui/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostList.test.js b/awx/ui/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostList.test.js index 1639c80f50..0b87981836 100644 --- a/awx/ui/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostList.test.js +++ b/awx/ui/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostList.test.js @@ -27,6 +27,21 @@ describe('', () => { InventoriesAPI.readHosts.mockResolvedValue({ data: mockHosts, }); + InventoriesAPI.readAdHocOptions.mockResolvedValue({ + data: { + actions: { + GET: { + module_name: { + choices: [ + ['command', 'command'], + ['shell', 'shell'], + ], + }, + }, + POST: {}, + }, + }, + }); await act(async () => { wrapper = mountWithContexts(