diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx index 06760f6809..d71d2c0fec 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx @@ -17,7 +17,7 @@ const QS_CONFIG = getQSConfig('inventory', { order_by: 'name', }); -function InventoryStep({ i18n }) { +function InventoryStep({ i18n, warningMessage = null }) { const [field, meta, helpers] = useField({ name: 'inventory', }); @@ -68,6 +68,7 @@ function InventoryStep({ i18n }) { return ( <> + {warningMessage} { expect(InventoriesAPI.read).toHaveBeenCalled(); expect(wrapper.find('OptionsList').prop('options')).toEqual(inventories); }); + + test('should show warning message when one is passed in', async () => { + let wrapper; + await act(async () => { + wrapper = mountWithContexts( + + TEST} + /> + + ); + }); + wrapper.update(); + + expect(wrapper.find('div#test-warning-message').length).toBe(1); + }); }); diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx index d81ee22e70..20c3d19da0 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx @@ -1,6 +1,7 @@ import React from 'react'; import { t } from '@lingui/macro'; import { useField } from 'formik'; +import { Alert } from '@patternfly/react-core'; import InventoryStep from './InventoryStep'; import StepName from './StepName'; @@ -21,7 +22,7 @@ export default function useInventoryStep( !meta.value; return { - step: getStep(launchConfig, i18n, formError), + step: getStep(launchConfig, i18n, formError, resource), initialValues: getInitialValues(launchConfig, resource), isReady: true, contentError: null, @@ -36,7 +37,7 @@ export default function useInventoryStep( }, }; } -function getStep(launchConfig, i18n, formError) { +function getStep(launchConfig, i18n, formError, resource) { if (!launchConfig.ask_inventory_on_launch) { return null; } @@ -47,7 +48,22 @@ function getStep(launchConfig, i18n, formError) { {i18n._(t`Inventory`)} ), - component: , + component: ( + + ) : null + } + /> + ), enableNext: true, }; }