diff --git a/awx/ui/client/src/templates/prompt/prompt.service.js b/awx/ui/client/src/templates/prompt/prompt.service.js index 00604da496..ee1b80ac97 100644 --- a/awx/ui/client/src/templates/prompt/prompt.service.js +++ b/awx/ui/client/src/templates/prompt/prompt.service.js @@ -25,14 +25,14 @@ function PromptService (Empty, $filter) { hasDefaultExtraVars = _.get(params, 'launchConf.defaults.extra_vars'); if(hasCurrentExtraVars && hasDefaultExtraVars) { - extraVars = _.merge(jsyaml.safeLoad(params.launchConf.defaults.extra_vars), params.currentValues.extra_data); + extraVars = jsyaml.safeDump(_.merge(jsyaml.safeLoad(params.launchConf.defaults.extra_vars), params.currentValues.extra_data)); } else if(hasCurrentExtraVars) { extraVars = params.currentValues.extra_data; } else if(hasDefaultExtraVars) { - extraVars = jsyaml.safeLoad(params.launchConf.defaults.extra_vars); + extraVars = params.launchConf.defaults.extra_vars; } - prompts.variables.value = extraVars && extraVars !== '' ? '---\n' + jsyaml.safeDump(extraVars) : '---\n'; + prompts.variables.value = extraVars && extraVars !== '' ? extraVars : '---\n'; prompts.verbosity.choices = _.get(params, 'launchOptions.actions.POST.verbosity.choices', []).map(c => ({label: c[1], value: c[0]})); prompts.verbosity.value = _.has(params, 'currentValues.verbosity') && params.currentValues.verbosity ? _.find(prompts.verbosity.choices, item => item.value === params.currentValues.verbosity) : _.find(prompts.verbosity.choices, item => item.value === params.launchConf.defaults.verbosity); prompts.jobType.choices = _.get(params, 'launchOptions.actions.POST.job_type.choices', []).map(c => ({label: c[1], value: c[0]})); diff --git a/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.controller.js b/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.controller.js index 1003ff0ec1..32ab75c786 100644 --- a/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.controller.js +++ b/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.controller.js @@ -11,11 +11,9 @@ export default vm.strings = strings; let scope; - let launch; - vm.init = (_scope_, _launch_) => { + vm.init = (_scope_) => { scope = _scope_; - launch = _launch_; scope.parseType = 'yaml'; diff --git a/awx/ui/client/src/templates/prompt/steps/preview/prompt-preview.controller.js b/awx/ui/client/src/templates/prompt/steps/preview/prompt-preview.controller.js index 9bbbb0130c..0895994041 100644 --- a/awx/ui/client/src/templates/prompt/steps/preview/prompt-preview.controller.js +++ b/awx/ui/client/src/templates/prompt/steps/preview/prompt-preview.controller.js @@ -11,7 +11,6 @@ export default vm.strings = strings; let scope; - let launch; let consolidateTags = (tagModel, tagId) => { let tags = angular.copy(tagModel); @@ -26,17 +25,14 @@ export default return [...tags.reduce((map, tag) => map.has(tag.value) ? map : map.set(tag.value, tag), new Map()).values()]; }; - vm.init = (_scope_, _launch_) => { + vm.init = (_scope_) => { scope = _scope_; - launch = _launch_; vm.showJobTags = true; vm.showSkipTags = true; scope.parseType = 'yaml'; - scope.promptData.extraVars = ToJSON(scope.parseType, scope.promptData.prompts.variables.value, false); - const surveyPasswords = {}; if (scope.promptData.launchConf.ask_tags_on_launch) { @@ -48,6 +44,7 @@ export default } if (scope.promptData.launchConf.survey_enabled){ + scope.promptData.extraVars = ToJSON(scope.parseType, scope.promptData.prompts.variables.value, false); scope.promptData.surveyQuestions.forEach(surveyQuestion => { if (!scope.promptData.extraVars) { scope.promptData.extraVars = {}; @@ -76,16 +73,18 @@ export default surveyPasswords[surveyQuestion.variable] = '$encrypted$'; } }); + // We don't want to modify the extra vars when we merge them with the survey + // password $encrypted$ strings so we clone it + const extraVarsClone = _.cloneDeep(scope.promptData.extraVars); + // Replace the survey passwords with $encrypted$ to display to the user + const cleansedExtraVars = extraVarsClone ? Object.assign(extraVarsClone, surveyPasswords) : {}; + + scope.promptExtraVars = $.isEmptyObject(scope.promptData.extraVars) ? '---' : '---\n' + jsyaml.safeDump(cleansedExtraVars); + } else { + scope.promptData.extraVars = scope.promptData.prompts.variables.value; + scope.promptExtraVars = scope.promptData.prompts.variables.value && scope.promptData.prompts.variables.value !== '' ? scope.promptData.prompts.variables.value : '---\n'; } - // We don't want to modify the extra vars when we merge them with the survey - // password $encrypted$ strings so we clone it - const extraVarsClone = _.cloneDeep(scope.promptData.extraVars); - // Replace the survey passwords with $encrypted$ to display to the user - const cleansedExtraVars = extraVarsClone ? Object.assign(extraVarsClone, surveyPasswords) : {}; - - scope.promptExtraVars = $.isEmptyObject(scope.promptData.extraVars) ? '---' : '---\n' + jsyaml.safeDump(cleansedExtraVars); - ParseTypeChange({ scope: scope, variable: 'promptExtraVars',