From 08381577f5542b3df6dd9a44d89ac5f6f79bb4d2 Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Thu, 16 Apr 2020 15:40:28 -0700 Subject: [PATCH] Merge prompt extra_vars before POSTing * Merge the extra_vars field with survey question responses before sending to API * Clean up select and multi-select survey fields --- .../src/components/FormField/FieldTooltip.jsx | 11 +- .../src/components/FormField/FormField.jsx | 34 +---- .../components/LaunchPrompt/LaunchPrompt.jsx | 4 +- .../components/LaunchPrompt/SurveyStep.jsx | 140 +++++++++++++----- .../components/LaunchPrompt/mergeExtraVars.js | 11 ++ .../LaunchPrompt/mergeExtraVars.test.js | 34 +++++ .../DeleteRoleConfirmationModal.test.jsx.snap | 2 + 7 files changed, 166 insertions(+), 70 deletions(-) create mode 100644 awx/ui_next/src/components/LaunchPrompt/mergeExtraVars.js create mode 100644 awx/ui_next/src/components/LaunchPrompt/mergeExtraVars.test.js diff --git a/awx/ui_next/src/components/FormField/FieldTooltip.jsx b/awx/ui_next/src/components/FormField/FieldTooltip.jsx index 59031bb365..56dfc43172 100644 --- a/awx/ui_next/src/components/FormField/FieldTooltip.jsx +++ b/awx/ui_next/src/components/FormField/FieldTooltip.jsx @@ -8,19 +8,26 @@ const QuestionCircleIcon = styled(PFQuestionCircleIcon)` margin-left: 10px; `; -function FieldTooltip({ content }) { +function FieldTooltip({ content, ...rest }) { + if (!content) { + return null; + } return ( ); } FieldTooltip.propTypes = { - content: node.isRequired, + content: node, +}; +FieldTooltip.defaultProps = { + content: null, }; export default FieldTooltip; diff --git a/awx/ui_next/src/components/FormField/FormField.jsx b/awx/ui_next/src/components/FormField/FormField.jsx index 49d77cfae3..c94c370e47 100644 --- a/awx/ui_next/src/components/FormField/FormField.jsx +++ b/awx/ui_next/src/components/FormField/FormField.jsx @@ -1,18 +1,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import { useField } from 'formik'; -import { - FormGroup, - TextInput, - TextArea, - Tooltip, -} from '@patternfly/react-core'; -import { QuestionCircleIcon as PFQuestionCircleIcon } from '@patternfly/react-icons'; -import styled from 'styled-components'; - -const QuestionCircleIcon = styled(PFQuestionCircleIcon)` - margin-left: 10px; -`; +import { FormGroup, TextInput, TextArea } from '@patternfly/react-core'; +import FieldTooltip from './FieldTooltip'; function FormField(props) { const { @@ -40,15 +30,7 @@ function FormField(props) { isValid={isValid} label={label} > - {tooltip && ( - - - - )} +