From 98b7f3b61890d8ee5715f757464343dda6fe8e19 Mon Sep 17 00:00:00 2001 From: mabashian Date: Thu, 6 Aug 2020 13:28:59 -0400 Subject: [PATCH 1/2] Support workflow prompting on launch --- .../src/components/LaunchPrompt/steps/InventoryStep.jsx | 2 -- .../components/LaunchPrompt/steps/useInventoryStep.jsx | 6 +++++- .../screens/Template/TemplateList/TemplateListItem.jsx | 9 +++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx index e7026c66b7..696809f547 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx @@ -9,7 +9,6 @@ import useRequest from '../../../util/useRequest'; import OptionsList from '../../OptionsList'; import ContentLoading from '../../ContentLoading'; import ContentError from '../../ContentError'; -import { required } from '../../../util/validators'; const QS_CONFIG = getQSConfig('inventory', { page: 1, @@ -20,7 +19,6 @@ const QS_CONFIG = getQSConfig('inventory', { function InventoryStep({ i18n }) { const [field, , helpers] = useField({ name: 'inventory', - validate: required(null, i18n), }); const history = useHistory(); diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx index aa8acbd6f6..ebc875d506 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx @@ -9,7 +9,11 @@ export default function useInventoryStep(config, resource, visitedSteps, i18n) { const [stepErrors, setStepErrors] = useState({}); const validate = values => { - if (!config.ask_inventory_on_launch) { + if ( + !config.ask_inventory_on_launch || + (['workflow_job', 'workflow_job_template'].includes(resource.type) && + !resource.inventory) + ) { return {}; } const errors = {}; diff --git a/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx b/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx index 716c83e608..16166ec108 100644 --- a/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx +++ b/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx @@ -44,9 +44,7 @@ function TemplateListItem({ fetchTemplates, }) { const [isDisabled, setIsDisabled] = useState(false); - const labelId = `check-action-${template.id}`; - const canLaunch = template.summary_fields.user_capabilities.start; const copyTemplate = useCallback(async () => { if (template.type === 'job_template') { @@ -105,8 +103,11 @@ function TemplateListItem({ , ]} /> - - {canLaunch && template.type === 'job_template' && ( + + {template.summary_fields.user_capabilities.start && ( {({ handleLaunch }) => ( From 1e9a71a2e4cd6d3d9ca3ef209ad77c381f47d582 Mon Sep 17 00:00:00 2001 From: mabashian Date: Thu, 13 Aug 2020 11:55:57 -0400 Subject: [PATCH 2/2] Run prettier --- .../src/screens/Template/TemplateList/TemplateListItem.jsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx b/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx index 16166ec108..eb0be40346 100644 --- a/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx +++ b/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx @@ -103,10 +103,7 @@ function TemplateListItem({ , ]} /> - + {template.summary_fields.user_capabilities.start && (