Sha256: 7272bc7a5890aadfbd09e0eb4a8d2905d69bce9d4c52ef18e52bd15a9a70e692

Contents?: true

Size: 1.32 KB

Versions: 15

Compression:

Stored size: 1.32 KB

Contents

import React, { useEffect } from 'react';
import { useDispatch, useSelector, shallowEqual } from 'react-redux';
import PropTypes from 'prop-types';
import { STATUS } from 'foremanReact/constants';
import EmptyStateMessage from '../components/EmptyStateMessage';
import Loading from '../components/Loading';
import getContentViewDetails from './ContentViewDetailActions';
import { selectCVDetails,
  selectCVDetailStatus,
  selectCVDetailError } from './ContentViewDetailSelectors';

const DetailsContainer = ({ children, cvId, isOpen }) => {
  const dispatch = useDispatch();
  const details = useSelector(state => selectCVDetails(state, cvId), shallowEqual);
  const status = useSelector(state => selectCVDetailStatus(state, cvId), shallowEqual);
  const error = useSelector(state => selectCVDetailError(state, cvId), shallowEqual);

  useEffect(() => {
    if (isOpen && Object.keys(details).length === 0) {
      dispatch(getContentViewDetails(cvId));
    }
  });

  if (status === STATUS.PENDING) return (<Loading size="sm" />);
  if (status === STATUS.ERROR) return (<EmptyStateMessage error={error} />);
  return (<React.Fragment>{children}</React.Fragment>);
};

DetailsContainer.propTypes = {
  children: PropTypes.element.isRequired,
  cvId: PropTypes.number.isRequired,
  isOpen: PropTypes.bool.isRequired,
};

export default DetailsContainer;

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
katello-3.16.2 webpack/scenes/ContentViews/details/DetailsContainer.js
katello-3.16.1.2 webpack/scenes/ContentViews/details/DetailsContainer.js
katello-3.16.1.1 webpack/scenes/ContentViews/details/DetailsContainer.js
katello-3.16.1 webpack/scenes/ContentViews/details/DetailsContainer.js
katello-3.16.0 webpack/scenes/ContentViews/details/DetailsContainer.js
katello-3.16.0.rc5.1 webpack/scenes/ContentViews/details/DetailsContainer.js
katello-3.16.0.rc5 webpack/scenes/ContentViews/details/DetailsContainer.js
katello-3.16.0.rc4.1 webpack/scenes/ContentViews/details/DetailsContainer.js
katello-3.16.0.rc4 webpack/scenes/ContentViews/details/DetailsContainer.js
katello-3.16.0.rc3.1 webpack/scenes/ContentViews/details/DetailsContainer.js
katello-3.16.0.rc3 webpack/scenes/ContentViews/details/DetailsContainer.js
katello-3.16.0.rc2.1 webpack/scenes/ContentViews/details/DetailsContainer.js
katello-3.16.0.rc2 webpack/scenes/ContentViews/details/DetailsContainer.js
katello-3.16.0.rc1.1 webpack/scenes/ContentViews/details/DetailsContainer.js
katello-3.16.0.rc1 webpack/scenes/ContentViews/details/DetailsContainer.js