From eda9bcbf6290faeb9ff28df98096a360924246d0 Mon Sep 17 00:00:00 2001 From: nixocio Date: Thu, 1 Apr 2021 15:58:18 -0400 Subject: [PATCH] Do not validate optional survey Do not validate optional survey. See: https://github.com/ansible/awx/issues/9176 --- .../src/components/LaunchPrompt/steps/SurveyStep.jsx | 6 +++--- awx/ui_next/src/util/prompt/getSurveyValues.js | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/SurveyStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/SurveyStep.jsx index f548870a51..cbe0d62fd2 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/SurveyStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/SurveyStep.jsx @@ -54,8 +54,8 @@ SurveyStep.propTypes = { function TextField({ question, i18n }) { const validators = [ question.required ? required(null, i18n) : null, - question.min ? minLength(question.min, i18n) : null, - question.max ? maxLength(question.max, i18n) : null, + question.required && question.min ? minLength(question.min, i18n) : null, + question.required && question.max ? maxLength(question.max, i18n) : null, ]; return ( 0; diff --git a/awx/ui_next/src/util/prompt/getSurveyValues.js b/awx/ui_next/src/util/prompt/getSurveyValues.js index 17b9fd1aed..0c29344563 100644 --- a/awx/ui_next/src/util/prompt/getSurveyValues.js +++ b/awx/ui_next/src/util/prompt/getSurveyValues.js @@ -5,6 +5,9 @@ export default function getSurveyValues(values) { if (Array.isArray(values[key]) && values[key].length === 0) { return; } + if (key.startsWith('survey_') && values[key] === '') { + return; + } surveyValues[key.substr(7)] = values[key]; } });