Sha256: 7ed9ceae74318d03d0346c892597c7be4e8cbe0d17875c4d54b906fb4021a1a8

Contents?: true

Size: 1.38 KB

Versions: 19

Compression:

Stored size: 1.38 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

19 entries across 19 versions & 1 rubygems

Version Path
foreman_rh_cloud-3.0.33 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-3.0.32 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-3.0.29 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-3.0.28 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-3.0.26 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-3.0.25 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-3.0.24.1 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-4.0.24.1 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-3.0.24 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-4.0.24 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-3.0.23 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-4.0.23 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-3.0.22 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-4.0.22 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-4.0.21.1 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-3.0.21.1 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-3.0.21 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-3.0.20 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-3.0.19 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js