Sha256: 484a7ed2c681a3720282bff0319c042ed0d1d29286c30ac3998028f3eb75b5ec

Contents?: true

Size: 1.12 KB

Versions: 58

Compression:

Stored size: 1.12 KB

Contents

import React, { useMemo } from 'react';
import { foremanUrl } from 'foremanReact/common/helpers';
import { useAPI } from 'foremanReact/common/hooks/API/APIHooks';
import Skeleton from 'react-loading-skeleton';
import { STATUS } from 'foremanReact/constants';

import PropTypes from 'prop-types';
import AnsibleHostInventory from './AnsibleHostInventory';
import ErrorState from '../../../ErrorState';

const WrappedAnsibleHostInventory = ({ hostId }) => {
  const params = useMemo(() => ({ params: { host_ids: [hostId] } }), [hostId]);

  const url = hostId && foremanUrl('/ansible/api/ansible_inventories/hosts');
  const { response: inventory, status } = useAPI('get', url, params);

  if (status === STATUS.PENDING) {
    return <Skeleton count={5} />;
  }

  if (status === STATUS.ERROR) {
    return (
      <ErrorState description={inventory?.response?.data?.error?.message} />
    );
  }

  return <AnsibleHostInventory inventoryData={inventory} />;
};

WrappedAnsibleHostInventory.propTypes = {
  hostId: PropTypes.number,
};

WrappedAnsibleHostInventory.defaultProps = {
  hostId: undefined,
};

export default WrappedAnsibleHostInventory;

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
foreman_ansible-12.0.5 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-10.4.3 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-12.0.4 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-10.4.2 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-12.0.3 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-12.0.2 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-12.0.1 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-12.0.0 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-11.2.1 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-7.1.7 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-11.2.0 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-11.1.2 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-7.1.6 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-11.1.1 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-10.4.1 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-7.1.5 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-11.1.0 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-10.4.0 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-10.3.0 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js
foreman_ansible-11.0.0 webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js