Sha256: c8561e0725adbdccf92a698d2ddf84c8fa9d6f023ce26dc947f724a860db9a6e

Contents?: true

Size: 1.37 KB

Versions: 12

Compression:

Stored size: 1.37 KB

Contents

/* eslint-disable react-hooks/exhaustive-deps */
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { FormGroup, TextInput } from '@patternfly/react-core';
import { noop } from 'foremanReact/common/helpers';
import { translate as __ } from 'foremanReact/common/I18n';
import ClearButton from './Components/ClearButton';
import './inventoryFilter.scss';
import { ANY_ORGANIZATION } from './InventoryFilterConstants';

const InventoryFilter = ({
  handleFilterChange,
  handleFilterClear,
  filterTerm,
  organization,
}) => {
  useEffect(() => {
    const initialTerm = organization === ANY_ORGANIZATION ? '' : organization;
    handleFilterChange(initialTerm);
  }, []);

  return (
    <form id="inventory_filter_form">
      <FormGroup>
        <TextInput
          id="inventory_filter_input"
          value={filterTerm}
          type="text"
          placeholder={__('Filter..')}
          onChange={handleFilterChange}
        />
        <ClearButton onClear={handleFilterClear} />
      </FormGroup>
    </form>
  );
};

InventoryFilter.propTypes = {
  handleFilterChange: PropTypes.func,
  handleFilterClear: PropTypes.func,
  filterTerm: PropTypes.string,
  organization: PropTypes.string,
};

InventoryFilter.defaultProps = {
  handleFilterChange: noop,
  handleFilterClear: noop,
  filterTerm: '',
  organization: '',
};

export default InventoryFilter;

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.36 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-4.0.35 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-4.0.32 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-4.0.31 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-4.0.30 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-4.0.29 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-5.0.29 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-5.0.28 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-4.0.27 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-4.0.26 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-4.0.25.1 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-4.0.25 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js