Sha256: 18fe5e7cb0cac71aa635758b1ad5eb3da4da92dda9e4ee412a01bcc169aa0421

Contents?: true

Size: 972 Bytes

Versions: 72

Compression:

Stored size: 972 Bytes

Contents

import React from 'react';
import { useSelector, useDispatch } from 'react-redux';
import URI from 'urijs';
import { SelectVariant } from '@patternfly/react-core';
import { get } from 'foremanReact/redux/API';
import { selectResponse, selectIsLoading } from '../../JobWizardSelectors';
import { SearchSelect } from '../form/SearchSelect';

export const useNameSearchAPI = (apiKey, url) => {
  const dispatch = useDispatch();
  const uri = new URI(url);
  const onSearch = search =>
    dispatch(
      get({
        key: apiKey,
        url: uri.addSearch({
          search: `name~"${search}"`,
        }),
      })
    );

  const response = useSelector(state => selectResponse(state, apiKey));
  const isLoading = useSelector(state => selectIsLoading(state, apiKey));
  return [onSearch, response, isLoading];
};

export const SelectAPI = props => (
  <SearchSelect
    {...props}
    variant={SelectVariant.typeaheadMulti}
    useNameSearch={useNameSearchAPI}
  />
);

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
foreman_remote_execution-13.2.7 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-15.0.0 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-14.1.4 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-14.1.3 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-14.1.2 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-14.1.1 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-14.1.0 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-14.0.2 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-14.0.1 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-13.2.6 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-14.0.0 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-13.2.5 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-13.2.4 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-13.2.3 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-13.2.2 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-12.0.7 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-13.2.1 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-13.2.0 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-10.1.3 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
foreman_remote_execution-13.0.0 webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js