mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 07:26:03 -03:30
Merge pull request #3359 from mabashian/yaml-comments
Show yaml comments when possible on launch prompt Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
@@ -25,14 +25,14 @@ function PromptService (Empty, $filter) {
|
|||||||
hasDefaultExtraVars = _.get(params, 'launchConf.defaults.extra_vars');
|
hasDefaultExtraVars = _.get(params, 'launchConf.defaults.extra_vars');
|
||||||
|
|
||||||
if(hasCurrentExtraVars && hasDefaultExtraVars) {
|
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) {
|
} else if(hasCurrentExtraVars) {
|
||||||
extraVars = params.currentValues.extra_data;
|
extraVars = params.currentValues.extra_data;
|
||||||
} else if(hasDefaultExtraVars) {
|
} 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.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.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]}));
|
prompts.jobType.choices = _.get(params, 'launchOptions.actions.POST.job_type.choices', []).map(c => ({label: c[1], value: c[0]}));
|
||||||
|
|||||||
@@ -11,11 +11,9 @@ export default
|
|||||||
vm.strings = strings;
|
vm.strings = strings;
|
||||||
|
|
||||||
let scope;
|
let scope;
|
||||||
let launch;
|
|
||||||
|
|
||||||
vm.init = (_scope_, _launch_) => {
|
vm.init = (_scope_) => {
|
||||||
scope = _scope_;
|
scope = _scope_;
|
||||||
launch = _launch_;
|
|
||||||
|
|
||||||
scope.parseType = 'yaml';
|
scope.parseType = 'yaml';
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ export default
|
|||||||
vm.strings = strings;
|
vm.strings = strings;
|
||||||
|
|
||||||
let scope;
|
let scope;
|
||||||
let launch;
|
|
||||||
|
|
||||||
let consolidateTags = (tagModel, tagId) => {
|
let consolidateTags = (tagModel, tagId) => {
|
||||||
let tags = angular.copy(tagModel);
|
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()];
|
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_;
|
scope = _scope_;
|
||||||
launch = _launch_;
|
|
||||||
|
|
||||||
vm.showJobTags = true;
|
vm.showJobTags = true;
|
||||||
vm.showSkipTags = true;
|
vm.showSkipTags = true;
|
||||||
|
|
||||||
scope.parseType = 'yaml';
|
scope.parseType = 'yaml';
|
||||||
|
|
||||||
scope.promptData.extraVars = ToJSON(scope.parseType, scope.promptData.prompts.variables.value, false);
|
|
||||||
|
|
||||||
const surveyPasswords = {};
|
const surveyPasswords = {};
|
||||||
|
|
||||||
if (scope.promptData.launchConf.ask_tags_on_launch) {
|
if (scope.promptData.launchConf.ask_tags_on_launch) {
|
||||||
@@ -48,6 +44,7 @@ export default
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (scope.promptData.launchConf.survey_enabled){
|
if (scope.promptData.launchConf.survey_enabled){
|
||||||
|
scope.promptData.extraVars = ToJSON(scope.parseType, scope.promptData.prompts.variables.value, false);
|
||||||
scope.promptData.surveyQuestions.forEach(surveyQuestion => {
|
scope.promptData.surveyQuestions.forEach(surveyQuestion => {
|
||||||
if (!scope.promptData.extraVars) {
|
if (!scope.promptData.extraVars) {
|
||||||
scope.promptData.extraVars = {};
|
scope.promptData.extraVars = {};
|
||||||
@@ -76,16 +73,18 @@ export default
|
|||||||
surveyPasswords[surveyQuestion.variable] = '$encrypted$';
|
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({
|
ParseTypeChange({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
variable: 'promptExtraVars',
|
variable: 'promptExtraVars',
|
||||||
|
|||||||
Reference in New Issue
Block a user