Sha256: 495f206da83618592dd90f9274c7fa62f2cb6c3421109d1a339de42ec1b9e159

Contents?: true

Size: 1.44 KB

Versions: 47

Compression:

Stored size: 1.44 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 { useForemanOrganization } from 'foremanReact/Root/Context/ForemanContext';
import ClearButton from './Components/ClearButton';
import './inventoryFilter.scss';
import { ANY_ORGANIZATION } from './InventoryFilterConstants';

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

  const organization = useForemanOrganization()?.title;

  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,
};

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

export default InventoryFilter;

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
foreman_rh_cloud-9.0.59 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-11.0.2 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-11.0.1 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-11.0.0 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-9.0.58 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-10.0.2 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-9.0.57 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-10.0.1 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-9.0.56 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-9.0.55 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-9.0.54 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-9.0.53 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-9.0.52 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-8.0.52 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-9.0.51 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-8.0.51 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-7.0.48 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-7.0.47 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-8.0.50 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js
foreman_rh_cloud-8.0.49 webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js