From 75746f2c6957e54386d173963d720c07712e4d32 Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 3 Mar 2021 13:20:30 -0500 Subject: [PATCH 1/3] Adds warning message to inventory step when launching wfjt or creating node with wfjt --- .../LaunchPrompt/steps/InventoryStep.jsx | 3 ++- .../LaunchPrompt/steps/InventoryStep.test.jsx | 16 ++++++++++++++ .../LaunchPrompt/steps/useInventoryStep.jsx | 22 ++++++++++++++++--- 3 files changed, 37 insertions(+), 4 deletions(-) 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, }; } From e9d524ebc0553071a70e0073d3934028ee5ab63d Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 3 Mar 2021 13:36:06 -0500 Subject: [PATCH 2/3] Space out the inventory warning --- .../components/LaunchPrompt/steps/useInventoryStep.jsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx index 20c3d19da0..03fd193758 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx @@ -1,10 +1,15 @@ import React from 'react'; import { t } from '@lingui/macro'; import { useField } from 'formik'; +import styled from 'styled-components'; import { Alert } from '@patternfly/react-core'; import InventoryStep from './InventoryStep'; import StepName from './StepName'; +const InventoryAlert = styled(Alert)` + margin-bottom: 16px; +`; + const STEP_ID = 'inventory'; export default function useInventoryStep( @@ -53,11 +58,11 @@ function getStep(launchConfig, i18n, formError, resource) { i18n={i18n} warningMessage={ resource.type === 'workflow_job_template' ? ( - ) : null From 9b1d6ab441ac75b191a1fff7a877b7a0269bbbef Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 3 Mar 2021 13:38:12 -0500 Subject: [PATCH 3/3] Adds ouiaId to inventory warning --- .../src/components/LaunchPrompt/steps/useInventoryStep.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx index 03fd193758..83d60bfa00 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx @@ -59,6 +59,7 @@ function getStep(launchConfig, i18n, formError, resource) { warningMessage={ resource.type === 'workflow_job_template' ? (