Sha256: c26930f592797e4e4cfc49966acb9bd4a1ffe86bbe5f115af7e9c881a177ade5

Contents?: true

Size: 986 Bytes

Versions: 2

Compression:

Stored size: 986 Bytes

Contents

import React from 'react';
import PropTypes from 'prop-types';
import TextInput from 'foremanReact/components/common/forms/TextInput';

const ExtTextInput = ({
  hidden,
  editable,
  viewText,
  label,
  onChange,
  additionalData,
}) => {
  if (hidden) {
    return null;
  }

  if (!editable) {
    return (
      <div className="form-group">
        <label className="col-md-2 control-label">{label}</label>
        <div className="col-md-4">{viewText}</div>
      </div>
    );
  }

  return (
    <TextInput
      label={label}
      value={viewText}
      onChange={e => onChange(e.target.value, additionalData)}
    />
  );
};

ExtTextInput.propTypes = {
  hidden: PropTypes.bool.isRequired,
  editable: PropTypes.bool.isRequired,
  viewText: PropTypes.string,
  label: PropTypes.string.isRequired,
  onChange: PropTypes.func.isRequired,
  additionalData: PropTypes.object,
};
ExtTextInput.defaultProps = {
  viewText: '',
  additionalData: {},
};

export default ExtTextInput;

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foreman_acd-0.11.0 webpack/components/common/ExtTextInput.js
foreman_acd-0.10.0 webpack/components/common/ExtTextInput.js