Sha256: 5eb1cd49d75895921f8a6bc8423a96eb3d43c9324897be5c2a4567b22d678ded
Contents?: true
Size: 1.56 KB
Versions: 19
Compression:
Stored size: 1.56 KB
Contents
import React from 'react'; import PropTypes from 'prop-types'; import { translate as __ } from 'foremanReact/common/I18n'; import { formatValue } from './AnsibleVariableOverridesTableHelper'; import { TextAreaField, TextInputField, SelectField, } from './EditableValueHelper'; const EditableValue = props => { if (!props.editing) { return formatValue(props.variable); } const type = props.variable.parameterType; if (type === 'array' || type === 'hash') { return ( <TextAreaField onChange={props.onChange} value={props.value} validation={props.validation} isDisabled={props.working} /> ); } if (type === 'boolean') { return ( <SelectField selectItems={[ { id: 'trueSelectOpt', value: true, name: __('true') }, { id: 'falseSelectOpt', value: false, name: __('false') }, ]} onChange={props.onChange} validation={props.validation} isDisabled={props.working} value={props.value} /> ); } return ( <TextInputField onChange={props.onChange} value={props.value} validation={props.validation} isDisabled={props.working} aria-label="Edit override field" /> ); }; EditableValue.propTypes = { editing: PropTypes.bool.isRequired, variable: PropTypes.object.isRequired, onChange: PropTypes.func.isRequired, value: PropTypes.any, validation: PropTypes.object.isRequired, working: PropTypes.bool.isRequired, }; EditableValue.defaultProps = { value: '', }; export default EditableValue;
Version data entries
19 entries across 19 versions & 1 rubygems