Sha256: 07a16a5bb3a0191be2228d9edc2abe34144985cee731ab13933735240f9008e2

Contents?: true

Size: 864 Bytes

Versions: 20

Compression:

Stored size: 864 Bytes

Contents

import React from 'react';
import { useSelector, useDispatch } from 'react-redux';
import URI from 'urijs';
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({
          name: search,
        }),
      })
    );
  };

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

export const ResourceSelectAPI = props => (
  <SearchSelect {...props} useNameSearch={useNameSearchAPI} />
);

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
foreman_remote_execution-7.2.2 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-7.2.1 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-7.2.0 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-5.0.8 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-8.0.0 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-7.1.1 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-7.1.0 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-7.0.0 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-5.0.7 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-5.0.6 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-6.2.0 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-5.0.5 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-6.1.0 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-5.0.4 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-5.0.3 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-6.0.0 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-5.0.2 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-5.1.0 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-5.0.1 webpack/JobWizard/steps/form/ResourceSelect.js
foreman_remote_execution-5.0.0 webpack/JobWizard/steps/form/ResourceSelect.js