diff --git a/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.jsx b/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.jsx index d3219c11d2..5e1eecb052 100644 --- a/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.jsx @@ -107,22 +107,21 @@ function LaunchPrompt({ config, resource = {}, onLaunch, onCancel, i18n }) { return ( onLaunch(values)} > diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx index 22b19fcc22..30e997875a 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx @@ -14,7 +14,7 @@ export default function useInventoryStep( nodeToEdit ) { const [, meta] = useField('inventory'); - const resource = nodeToEdit || selectedResource; + const resource = nodeToEdit?.originalNodeObject || nodeToEdit?.promptValues || selectedResource; const formError = Object.keys(visitedSteps).includes(STEP_ID) && (!meta.value || meta.error); @@ -50,6 +50,6 @@ function getInitialValues(config, resource) { } return { - inventory: resource?.summary_fields?.inventory, + inventory: resource?.summary_fields?.inventory || resource?.inventory || null, }; } diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/usePreviewStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/usePreviewStep.jsx index 423ac3caf1..de60246b64 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/usePreviewStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/usePreviewStep.jsx @@ -10,10 +10,12 @@ export default function usePreviewStep( resource, survey, hasErrors, - needsPreviewStep + needsPreviewStep, + nodeToEdit ) { const showStep = needsPreviewStep && resource && Object.keys(config).length > 0; + const promptResource = nodeToEdit || resource return { step: showStep ? { @@ -23,7 +25,7 @@ export default function usePreviewStep( component: ( diff --git a/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx index a59fd7ba7f..2e8eb9510b 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx @@ -67,10 +67,11 @@ function hasPromptData(launchData) { ); } -function omitOverrides(resource, overrides) { +function omitOverrides(resource, overrides, defaultConfig) { const clonedResource = { ...resource, summary_fields: { ...resource.summary_fields }, + ...defaultConfig }; Object.keys(overrides).forEach(keyToOmit => { delete clonedResource[keyToOmit]; @@ -88,7 +89,8 @@ function PromptDetail({ i18n, resource, launchConfig = {}, overrides = {} }) { 4: i18n._(t`4 (Connection Debug)`), }; - const details = omitOverrides(resource, overrides); + const details = omitOverrides(resource, overrides, launchConfig.defaults); + details.type = overrides?.nodeType || details.type const hasOverrides = Object.keys(overrides).length > 0; return ( @@ -137,13 +139,13 @@ function PromptDetail({ i18n, resource, launchConfig = {}, overrides = {} }) { {i18n._(t`Prompted Values`)} - {overrides?.job_type && ( + {launchConfig.ask_job_type_on_launch && ( )} - {overrides?.credentials?.length > 0 && ( + {launchConfig.ask_credential_on_launch && ( )} - {overrides?.inventory && ( + {launchConfig.ask_inventory_on_launch && ( )} - {overrides?.scm_branch && ( + {launchConfig.ask_scm_branch_on_launch && ( )} - {overrides?.limit && ( + {launchConfig.ask_limit_on_launch && ( )} - {overrides?.verbosity && ( + {overrides?.verbosity && launchConfig.ask_verbosity_on_launch && ( )} - {overrides?.job_tags && ( + {launchConfig.ask_tags_on_launch && ( )} - {overrides?.skip_tags && ( + {launchConfig.ask_skip_tags_on_launch && ( )} - {overrides?.diff_mode && ( + {launchConfig.ask_diff_mode_on_launch && ( )} - {overrides?.extra_vars && ( + {launchConfig.ask_variables_on_launch && ( { if ( - (nodeTypeField.value !== 'approval' && nodeResouceField.value === null) || + (nodeTypeField.value !== 'approval' && nodeResourceField.value === null) || (nodeTypeField.value === 'approval' && approvalNameField.value === undefined) ) { @@ -61,7 +61,8 @@ function getInitialValues(nodeToEdit) { typeOfNode = { nodeType: 'job_template', nodeResource: - nodeToEdit.originalNodeObject.summary_fields.unified_job_template, + nodeToEdit.originalNodeObject?.summary_fields?.unified_job_template + || nodeToEdit.unifiedJobTemplate, }; if (unifiedType === 'project' || unifiedType === 'project_update') { typeOfNode = { nodeType: 'project_sync' }; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/useWorkflowNodeSteps.js b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/useWorkflowNodeSteps.js index 18b47b53b6..1c49868a4b 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/useWorkflowNodeSteps.js +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/useWorkflowNodeSteps.js @@ -25,7 +25,7 @@ export default function useWorkflowNodeSteps( i18n, visited, resource, - nodeToEdit?.originalNodeObject + nodeToEdit ), useCredentialsStep(config, i18n, resource, nodeToEdit?.originalNodeObject), useOtherPromptsStep(config, i18n, resource, nodeToEdit?.originalNodeObject), @@ -48,7 +48,8 @@ export default function useWorkflowNodeSteps( resource, steps[surveyStepIndex]?.survey, hasErrors, - needsPreviewStep + needsPreviewStep, + nodeToEdit?.originalNodeObject ) ); @@ -65,7 +66,7 @@ export default function useWorkflowNodeSteps( resetForm({ values: { ...initialValues, - nodeResource: formikValues.nodeResource, + nodeResource: formikValues.nodeResource || initialValues.nodeResource, nodeType: formikValues.nodeType || initialValues.nodeType, linkType: formikValues.linkType || 'success', verbosity: initialValues?.verbosity?.toString(), diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Visualizer.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Visualizer.jsx index 1af3651c54..9b9505d52c 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Visualizer.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Visualizer.jsx @@ -308,9 +308,10 @@ function Visualizer({ template, i18n }) { ) ); } else { + node.promptValues.inventory = node.promptValues?.inventory?.id nodeRequests.push( WorkflowJobTemplatesAPI.createNode(template.id, { - ...node.promptValues, + ...node.promptValues, unified_job_template: node.unifiedJobTemplate.id, }).then(({ data }) => { node.originalNodeObject = data;