diff --git a/src/components/AnsibleSelect/AnsibleSelect.jsx b/src/components/AnsibleSelect/AnsibleSelect.jsx index fe6e352811..60bf385c88 100644 --- a/src/components/AnsibleSelect/AnsibleSelect.jsx +++ b/src/components/AnsibleSelect/AnsibleSelect.jsx @@ -20,7 +20,8 @@ class AnsibleSelect extends React.Component { } render () { - const { label, value, data, defaultSelected, i18n } = this.props; + const { value, data, i18n } = this.props; + return ( {data.map((datum) => ( - datum === defaultSelected ? ( - - ) : ( - - ) + ))} ); @@ -45,15 +43,10 @@ class AnsibleSelect extends React.Component { AnsibleSelect.defaultProps = { data: [], - label: 'Ansible Select', - defaultSelected: null, }; AnsibleSelect.propTypes = { - data: PropTypes.arrayOf(PropTypes.string), - defaultSelected: PropTypes.string, - label: PropTypes.string, - name: PropTypes.string.isRequired, + data: PropTypes.arrayOf(PropTypes.object), onChange: PropTypes.func.isRequired, value: PropTypes.string.isRequired, }; diff --git a/src/components/AnsibleSelect/AnsibleSelect.test.jsx b/src/components/AnsibleSelect/AnsibleSelect.test.jsx index d3be54f5d7..7077f08ff8 100644 --- a/src/components/AnsibleSelect/AnsibleSelect.test.jsx +++ b/src/components/AnsibleSelect/AnsibleSelect.test.jsx @@ -2,8 +2,17 @@ import React from 'react'; import { mountWithContexts } from '../../../testUtils/enzymeHelpers'; import AnsibleSelect, { _AnsibleSelect } from './AnsibleSelect'; -const label = 'test select'; -const mockData = ['/venv/baz/', '/venv/ansible/']; +const mockData = [ + { + label: 'Baz', + value: '/venv/baz/' + }, + { + label: 'Default', + value: '/venv/ansible/' + } +]; + describe('', () => { test('initially renders succesfully', async () => { mountWithContexts( @@ -11,7 +20,6 @@ describe('', () => { value="foo" name="bar" onChange={() => { }} - label={label} data={mockData} /> ); @@ -24,7 +32,6 @@ describe('', () => { value="foo" name="bar" onChange={() => { }} - label={label} data={mockData} /> ); @@ -33,17 +40,17 @@ describe('', () => { expect(spy).toHaveBeenCalled(); }); - test('Returns correct select options if defaultSelected props is passed', () => { + test('Returns correct select options', () => { const wrapper = mountWithContexts( { }} - label={label} data={mockData} - defaultSelected={mockData[1]} /> ); + expect(wrapper.find('FormSelect')).toHaveLength(1); + expect(wrapper.find('FormSelectOption')).toHaveLength(2); }); }); diff --git a/src/components/FormActionGroup/FormActionGroup.jsx b/src/components/FormActionGroup/FormActionGroup.jsx index 7a91e72c15..634212ff07 100644 --- a/src/components/FormActionGroup/FormActionGroup.jsx +++ b/src/components/FormActionGroup/FormActionGroup.jsx @@ -4,29 +4,31 @@ import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { ActionGroup as PFActionGroup, - Toolbar, - ToolbarGroup, Button } from '@patternfly/react-core'; import styled from 'styled-components'; const ActionGroup = styled(PFActionGroup)` - display: flex; - flex-direction: row; - justify-content: flex-end; - --pf-c-form__group--m-action--MarginTop: 0; + display: flex; + justify-content: flex-end; + --pf-c-form__group--m-action--MarginTop: 0; + + .pf-c-form__actions { + display: grid; + gap: 24px; + grid-template-columns: auto auto; + margin: 0; + + & > button { + margin: 0; + } + } `; const FormActionGroup = ({ onSubmit, submitDisabled, onCancel, i18n }) => ( - - - - - - - - + + ); diff --git a/src/components/FormField/FormField.jsx b/src/components/FormField/FormField.jsx index b31297fa48..2833226a26 100644 --- a/src/components/FormField/FormField.jsx +++ b/src/components/FormField/FormField.jsx @@ -1,10 +1,16 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Field } from 'formik'; -import { FormGroup, TextInput } from '@patternfly/react-core'; +import { FormGroup, TextInput, 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; +`; function FormField (props) { - const { id, name, label, validate, isRequired, ...rest } = props; + const { id, name, label, tooltip, validate, isRequired, ...rest } = props; return ( + {tooltip && ( + + + + + )} {}, isRequired: false, + tooltip: null }; export default FormField; diff --git a/src/screens/Organization/OrganizationAdd/OrganizationAdd.test.jsx b/src/screens/Organization/OrganizationAdd/OrganizationAdd.test.jsx index 595854955a..386344f577 100644 --- a/src/screens/Organization/OrganizationAdd/OrganizationAdd.test.jsx +++ b/src/screens/Organization/OrganizationAdd/OrganizationAdd.test.jsx @@ -105,7 +105,8 @@ describe('', () => { { context: { config } } ).find('AnsibleSelect'); expect(wrapper.find('FormSelect')).toHaveLength(1); - expect(wrapper.find('FormSelectOption')).toHaveLength(2); + expect(wrapper.find('FormSelectOption')).toHaveLength(3); + expect(wrapper.find('FormSelectOption').first().prop('value')).toEqual('/venv/ansible/'); }); test('AnsibleSelect component does not render if there are 0 virtual environments', () => { diff --git a/src/screens/Organization/shared/OrganizationForm.jsx b/src/screens/Organization/shared/OrganizationForm.jsx index 9a200b15af..8d58afb3d5 100644 --- a/src/screens/Organization/shared/OrganizationForm.jsx +++ b/src/screens/Organization/shared/OrganizationForm.jsx @@ -93,7 +93,11 @@ class OrganizationForm extends Component { render () { const { organization, handleCancel, i18n, me } = this.props; const { instanceGroups, formIsValid, error } = this.state; - const defaultVenv = '/venv/ansible/'; + const defaultVenv = { + label: i18n._(t`Use Default Ansible Environment`), + value: '/venv/ansible/', + key: 'default' + }; return ( @@ -156,9 +163,10 @@ class OrganizationForm extends Component { label={i18n._(t`Ansible Environment`)} > datum !== defaultVenv.value) + .map(datum => ({ label: datum, value: datum, key: datum })) + ]} {...field} /> diff --git a/src/screens/Organization/shared/OrganizationForm.test.jsx b/src/screens/Organization/shared/OrganizationForm.test.jsx index 1be9d34de3..e1bd876e54 100644 --- a/src/screens/Organization/shared/OrganizationForm.test.jsx +++ b/src/screens/Organization/shared/OrganizationForm.test.jsx @@ -144,7 +144,8 @@ describe('', () => { } ); expect(wrapper.find('FormSelect')).toHaveLength(1); - expect(wrapper.find('FormSelectOption')).toHaveLength(2); + expect(wrapper.find('FormSelectOption')).toHaveLength(3); + expect(wrapper.find('FormSelectOption').first().prop('value')).toEqual('/venv/ansible/'); }); test('calls handleSubmit when form submitted', async () => { diff --git a/src/screens/Template/JobTemplateDetail/JobTemplateDetail.jsx b/src/screens/Template/JobTemplateDetail/JobTemplateDetail.jsx index b7e1764f18..61ce33ca0a 100644 --- a/src/screens/Template/JobTemplateDetail/JobTemplateDetail.jsx +++ b/src/screens/Template/JobTemplateDetail/JobTemplateDetail.jsx @@ -75,6 +75,7 @@ class JobTemplateDetail extends Component { }, hasTemplateLoading, i18n, + match, } = this.props; const { instanceGroups, hasContentLoading, contentError } = this.state; const verbosityOptions = [ @@ -307,7 +308,7 @@ class JobTemplateDetail extends Component { {summary_fields.user_capabilities.edit && (