From 19ef91f2aaa7d575a74ab515bc283c233358a955 Mon Sep 17 00:00:00 2001 From: mabashian Date: Mon, 23 Apr 2018 12:26:07 -0400 Subject: [PATCH] Fixed bug where vault password prompt was not being hidden after removing default credential --- .../launchTemplateButton.component.js | 2 +- .../src/templates/prompt/prompt.controller.js | 30 ++++++++++++------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/awx/ui/client/lib/components/launchTemplateButton/launchTemplateButton.component.js b/awx/ui/client/lib/components/launchTemplateButton/launchTemplateButton.component.js index 40dcf2907c..bd82a2fa10 100644 --- a/awx/ui/client/lib/components/launchTemplateButton/launchTemplateButton.component.js +++ b/awx/ui/client/lib/components/launchTemplateButton/launchTemplateButton.component.js @@ -53,7 +53,7 @@ function atLaunchTemplateCtrl ( launchConf: launchData.data, launchOptions: launchOptions.data }), - triggerModalOpen: true, + triggerModalOpen: true }; if (launchData.data.survey_enabled) { diff --git a/awx/ui/client/src/templates/prompt/prompt.controller.js b/awx/ui/client/src/templates/prompt/prompt.controller.js index 133121e6fd..7c1c69fbb1 100644 --- a/awx/ui/client/src/templates/prompt/prompt.controller.js +++ b/awx/ui/client/src/templates/prompt/prompt.controller.js @@ -70,29 +70,37 @@ export default [ 'Rest', 'GetBasePath', 'ProcessErrors', 'CredentialTypeModel', vm.promptDataClone.prompts.credentials.passwords = {}; - if(vm.promptData.launchConf.passwords_needed_to_start) { - vm.promptData.launchConf.passwords_needed_to_start.forEach((passwordNeeded) => { + if(vm.promptDataClone.launchConf.passwords_needed_to_start) { + vm.promptDataClone.launchConf.passwords_needed_to_start.forEach((passwordNeeded) => { if(passwordNeeded === "ssh_password") { - vm.promptData.prompts.credentials.passwords.ssh = {}; + vm.promptDataClone.prompts.credentials.passwords.ssh = {}; } if(passwordNeeded === "become_password") { - vm.promptData.prompts.credentials.passwords.become = {}; + vm.promptDataClone.prompts.credentials.passwords.become = {}; } if(passwordNeeded === "ssh_key_unlock") { - vm.promptData.prompts.credentials.passwords.ssh_key_unlock = {}; + vm.promptDataClone.prompts.credentials.passwords.ssh_key_unlock = {}; } if(passwordNeeded.startsWith("vault_password")) { - let vault_id; - if(passwordNeeded.includes('.')) { + let vault_id = null; + if (passwordNeeded.includes('.')) { vault_id = passwordNeeded.split(/\.(.+)/)[1]; } - if(!vm.promptData.prompts.credentials.passwords.vault) { - vm.promptData.prompts.credentials.passwords.vault = []; + if (!vm.promptDataClone.prompts.credentials.passwords.vault) { + vm.promptDataClone.prompts.credentials.passwords.vault = []; } - vm.promptData.prompts.credentials.passwords.vault.push({ - vault_id: vault_id + // Loop across the default credentials to find the name of the + // credential that requires a password + vm.promptDataClone.prompts.credentials.value.forEach((defaultCredential) => { + if (defaultCredential.vault_id === vault_id) { + vm.promptDataClone.prompts.credentials.passwords.vault.push({ + id: defaultCredential.id, + name: defaultCredential.name, + vault_id: defaultCredential.vault_id + }); + } }); } });