mirror of
https://github.com/ansible/awx.git
synced 2026-03-29 06:45:09 -02:30
fix merging of survey values into extra_vars
This commit is contained in:
@@ -7,6 +7,7 @@ import ContentError from '@components/ContentError';
|
|||||||
import ContentLoading from '@components/ContentLoading';
|
import ContentLoading from '@components/ContentLoading';
|
||||||
import mergeExtraVars from './mergeExtraVars';
|
import mergeExtraVars from './mergeExtraVars';
|
||||||
import useSteps from './useSteps';
|
import useSteps from './useSteps';
|
||||||
|
import getSurveyValues from './getSurveyValues';
|
||||||
|
|
||||||
function LaunchPrompt({ config, resource, onLaunch, onCancel, i18n }) {
|
function LaunchPrompt({ config, resource, onLaunch, onCancel, i18n }) {
|
||||||
const {
|
const {
|
||||||
@@ -33,13 +34,14 @@ function LaunchPrompt({ config, resource, onLaunch, onCancel, i18n }) {
|
|||||||
postValues[key] = value;
|
postValues[key] = value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const surveyValues = getSurveyValues(values);
|
||||||
setValue('inventory_id', values.inventory?.id);
|
setValue('inventory_id', values.inventory?.id);
|
||||||
setValue('credentials', values.credentials?.map(c => c.id));
|
setValue('credentials', values.credentials?.map(c => c.id));
|
||||||
setValue('job_type', values.job_type);
|
setValue('job_type', values.job_type);
|
||||||
setValue('limit', values.limit);
|
setValue('limit', values.limit);
|
||||||
setValue('job_tags', values.job_tags);
|
setValue('job_tags', values.job_tags);
|
||||||
setValue('skip_tags', values.skip_tags);
|
setValue('skip_tags', values.skip_tags);
|
||||||
setValue('extra_vars', mergeExtraVars(values.extra_vars, values.survey));
|
setValue('extra_vars', mergeExtraVars(values.extra_vars, surveyValues));
|
||||||
onLaunch(postValues);
|
onLaunch(postValues);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export default function getSurveyValues(values) {
|
||||||
|
const surveyValues = {};
|
||||||
|
Object.keys(values).forEach(key => {
|
||||||
|
if (key.startsWith('survey_')) {
|
||||||
|
surveyValues[key.substr(7)] = values[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return surveyValues;
|
||||||
|
}
|
||||||
@@ -3,13 +3,15 @@ import { useFormikContext } from 'formik';
|
|||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import PromptDetail from '@components/PromptDetail';
|
import PromptDetail from '@components/PromptDetail';
|
||||||
import mergeExtraVars, { maskPasswords } from '../mergeExtraVars';
|
import mergeExtraVars, { maskPasswords } from '../mergeExtraVars';
|
||||||
|
import getSurveyValues from '../getSurveyValues';
|
||||||
|
|
||||||
function PreviewStep({ resource, config, survey, formErrors }) {
|
function PreviewStep({ resource, config, survey, formErrors }) {
|
||||||
const { values } = useFormikContext();
|
const { values } = useFormikContext();
|
||||||
|
const surveyValues = getSurveyValues(values);
|
||||||
const passwordFields = survey.spec
|
const passwordFields = survey.spec
|
||||||
.filter(q => q.type === 'password')
|
.filter(q => q.type === 'password')
|
||||||
.map(q => q.variable);
|
.map(q => q.variable);
|
||||||
const masked = maskPasswords(values.survey, passwordFields);
|
const masked = maskPasswords(surveyValues, passwordFields);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PromptDetail
|
<PromptDetail
|
||||||
|
|||||||
Reference in New Issue
Block a user