From cdb51a75b8b33014a0ebd8e744d4a74cfdcec0c1 Mon Sep 17 00:00:00 2001 From: mabashian Date: Tue, 11 Oct 2022 09:46:33 -0400 Subject: [PATCH 1/2] Fixes bug re-launching adhoc command with passwords required --- awx/ui/src/components/LaunchPrompt/LaunchPrompt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/src/components/LaunchPrompt/LaunchPrompt.js b/awx/ui/src/components/LaunchPrompt/LaunchPrompt.js index 005c9069e9..3b7f9e9d35 100644 --- a/awx/ui/src/components/LaunchPrompt/LaunchPrompt.js +++ b/awx/ui/src/components/LaunchPrompt/LaunchPrompt.js @@ -129,7 +129,7 @@ function PromptModalForm({ }} title={t`Launch | ${resource.name}`} description={ - resource.description.length > 512 ? ( + resource.description?.length > 512 ? ( Date: Tue, 11 Oct 2022 11:36:05 -0400 Subject: [PATCH 2/2] Fixes bug where relaunching adhoc command did not work --- awx/ui/src/components/LaunchButton/LaunchButton.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/awx/ui/src/components/LaunchButton/LaunchButton.js b/awx/ui/src/components/LaunchButton/LaunchButton.js index 5f207e3be7..909441b2c9 100644 --- a/awx/ui/src/components/LaunchButton/LaunchButton.js +++ b/awx/ui/src/components/LaunchButton/LaunchButton.js @@ -107,6 +107,17 @@ function LaunchButton({ resource, children }) { jobPromise = JobsAPI.relaunch(resource.id, params || {}); } else if (resource.type === 'workflow_job') { jobPromise = WorkflowJobsAPI.relaunch(resource.id, params || {}); + } else if (resource.type === 'ad_hoc_command') { + if (params?.credential_passwords) { + // The api expects the passwords at the top level of the object instead of nested + // in credential_passwords like the other relaunch endpoints + Object.keys(params.credential_passwords).forEach((key) => { + params[key] = params.credential_passwords[key]; + }); + + delete params.credential_passwords; + } + jobPromise = AdHocCommandsAPI.relaunch(resource.id, params || {}); } const { data: job } = await jobPromise;