From 9c218fa5f5bb9fcd1dbeaef5458817769d59465e Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Mon, 6 Apr 2020 17:31:52 -0700 Subject: [PATCH] flush out prompt misc fields --- .../components/LaunchPrompt/LaunchPrompt.jsx | 23 ++-- .../LaunchPrompt/OtherPromptsStep.jsx | 125 +++++++++++++++++- 2 files changed, 131 insertions(+), 17 deletions(-) diff --git a/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.jsx b/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.jsx index 3743168953..a932aee367 100644 --- a/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.jsx @@ -19,14 +19,6 @@ function LaunchPrompt({ config, resource, onLaunch, onCancel, i18n }) { component: , }); } - // TODO: match old UI Logic: - // if (vm.promptDataClone.launchConf.ask_credential_on_launch || - // (_.has(vm, 'promptDataClone.prompts.credentials.passwords.vault') && - // vm.promptDataClone.prompts.credentials.passwords.vault.length > 0) || - // _.has(vm, 'promptDataClone.prompts.credentials.passwords.ssh_key_unlock') || - // _.has(vm, 'promptDataClone.prompts.credentials.passwords.become_password') || - // _.has(vm, 'promptDataClone.prompts.credentials.passwords.ssh_password') - // ) { if (config.ask_credential_on_launch) { initialValues.credentials = resource?.summary_fields?.credentials || []; steps.push({ @@ -34,15 +26,18 @@ function LaunchPrompt({ config, resource, onLaunch, onCancel, i18n }) { component: , }); } + + // TODO: Add Credential Passwords step + if ( - config.ask_scm_branch_on_launch || - (config.ask_variables_on_launch && !config.ignore_ask_variables) || - config.ask_tags_on_launch || - config.ask_diff_mode_on_launch || - config.ask_skip_tags_on_launch || config.ask_job_type_on_launch || config.ask_limit_on_launch || - config.ask_verbosity_on_launch + config.ask_verbosity_on_launch || + config.ask_tags_on_launch || + config.ask_skip_tags_on_launch || + config.ask_variables_on_launch || + config.ask_scm_branch_on_launch || + config.ask_diff_mode_on_launch ) { steps.push({ name: i18n._(t`Other Prompts`), diff --git a/awx/ui_next/src/components/LaunchPrompt/OtherPromptsStep.jsx b/awx/ui_next/src/components/LaunchPrompt/OtherPromptsStep.jsx index c0b8e6ec14..826f90c86f 100644 --- a/awx/ui_next/src/components/LaunchPrompt/OtherPromptsStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/OtherPromptsStep.jsx @@ -1,7 +1,126 @@ import React from 'react'; +import { withI18n } from '@lingui/react'; +import { t } from '@lingui/macro'; +import { useField } from 'formik'; +import { FormGroup } from '@patternfly/react-core'; +import FormField, { FieldTooltip } from '@components/FormField'; +import { TagMultiSelect } from '@components/MultiSelect'; +import AnsibleSelect from '@components/AnsibleSelect'; +import { VariablesField } from '@components/CodeMirrorInput'; -function InventoryStep() { - return
; +function OtherPromptsStep({ config, i18n }) { + return ( + <> + {config.ask_job_type_on_launch && ( + + )} + {config.ask_limit_on_launch && ( + + )} + {config.ask_verbosity_on_launch && } + {/* TODO: Show Changes toggle? */} + {config.ask_tags_on_launch && ( + + )} + {config.ask_skip_tags_on_launch && ( + + )} + {config.ask_variables_on_launch && ( + + )} + + ); } -export default InventoryStep; +function VerbosityField({ i18n }) { + const [field, meta] = useField('verbosity'); + const options = [ + { value: '0', key: '0', label: i18n._(t`0 (Normal)`) }, + { value: '1', key: '1', label: i18n._(t`1 (Verbose)`) }, + { value: '2', key: '2', label: i18n._(t`2 (More Verbose)`) }, + { value: '3', key: '3', label: i18n._(t`3 (Debug)`) }, + { value: '4', key: '4', label: i18n._(t`4 (Connection Debug)`) }, + ]; + const isValid = !(meta.touched && meta.error); + + return ( + + + + + ); +} + +function TagField({ id, name, label, tooltip }) { + const [field, , helpers] = useField(name); + return ( + + + + + ); +} + +/* + tooltips: + verbosity: Control the level of output ansible will produce as the playbook executes. + job tags: Tags are useful when you have a large playbook, and you want to run a specific part of a play or task. Use commas to separate multiple tags. Refer to Ansible Tower documentation for details on the usage of tags. + skip tags: Skip tags are useful when you have a large playbook, and you want to skip specific parts of a play or task. Use commas to separate multiple tags. Refer to Ansible Tower documentation for details on the usage of tags. + show changes: If enabled, show the changes made by Ansible tasks, where supported. This is equivalent to Ansible’s --diff mode. + extra variables: Pass extra command line variables to the playbook. This is the -e or --extra-vars command line parameter for ansible-playbook. Provide key/value pairs using either YAML or JSON. + + JSON: + { + "somevar": "somevalue", + "password": "magic" + } + YAML: + --- + somevar: somevalue + password: magic +*/ + +export default withI18n()(OtherPromptsStep);