Sha256: fa2c1bfb6fc6a59eb1b5bb7bc60ae61caa4d182eafd2a49de78a3d81cc93186f

Contents?: true

Size: 1.83 KB

Versions: 67

Compression:

Stored size: 1.83 KB

Contents

import React, { useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import {
  TextContent,
  TextList,
  TextListVariants,
  TextListItem,
  TextListItemVariants,
} from '@patternfly/react-core';
import { STATUS } from 'foremanReact/constants';
import PropTypes from 'prop-types';
import { selectContentDetails, selectContentDetailsStatus } from '../ContentSelectors';
import contentConfig from '../ContentConfig';
import { getContentDetails } from '../ContentActions';
import Loading from '../../../components/Loading';
/* eslint-disable react/no-array-index-key */
const ContentInfo = ({ contentType, id, tabKey }) => {
  const dispatch = useDispatch();
  const detailsResponse = useSelector(selectContentDetails);
  const detailsStatus = useSelector(selectContentDetailsStatus);

  const config = contentConfig.find(type => type.names.pluralLabel === contentType);
  const { columnHeaders } = config.tabs.find(header => header.tabKey === tabKey);

  useEffect(() => {
    if (!detailsResponse) {
      dispatch(getContentDetails(contentType, id));
    }
  });

  if (detailsStatus === STATUS.PENDING) {
    return <Loading />;
  }

  return (
    <TextContent className="margin-0-24">
      <TextList component={TextListVariants.dl}>
        {columnHeaders.map((col, index) => [
          <TextListItem
            key={`${index}_${col.title}`}
            component={TextListItemVariants.dt}
          > {col.title}
          </TextListItem>,
          <TextListItem
            key={index}
            component={TextListItemVariants.dd}
          > {col.getProperty(detailsResponse)}
          </TextListItem>])}
      </TextList>
    </TextContent>
  );
};

export default ContentInfo;

ContentInfo.propTypes = {
  contentType: PropTypes.string.isRequired,
  id: PropTypes.number.isRequired,
  tabKey: PropTypes.string.isRequired,
};

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
katello-4.14.3 webpack/scenes/Content/Details/ContentInfo.js
katello-4.14.2 webpack/scenes/Content/Details/ContentInfo.js
katello-4.15.0 webpack/scenes/Content/Details/ContentInfo.js
katello-4.15.0.rc2 webpack/scenes/Content/Details/ContentInfo.js
katello-4.15.0.rc1 webpack/scenes/Content/Details/ContentInfo.js
katello-4.14.1 webpack/scenes/Content/Details/ContentInfo.js
katello-4.14.0 webpack/scenes/Content/Details/ContentInfo.js
katello-4.14.0.rc3 webpack/scenes/Content/Details/ContentInfo.js
katello-4.14.0.rc2 webpack/scenes/Content/Details/ContentInfo.js
katello-4.14.0.rc1.1 webpack/scenes/Content/Details/ContentInfo.js
katello-4.14.0.rc1 webpack/scenes/Content/Details/ContentInfo.js
katello-4.13.1 webpack/scenes/Content/Details/ContentInfo.js
katello-4.13.0 webpack/scenes/Content/Details/ContentInfo.js
katello-4.12.1 webpack/scenes/Content/Details/ContentInfo.js
katello-4.13.0.rc1 webpack/scenes/Content/Details/ContentInfo.js
katello-4.12.0 webpack/scenes/Content/Details/ContentInfo.js
katello-4.12.0.rc3 webpack/scenes/Content/Details/ContentInfo.js
katello-4.12.0.rc2 webpack/scenes/Content/Details/ContentInfo.js
katello-4.12.0.rc1 webpack/scenes/Content/Details/ContentInfo.js
katello-4.11.1 webpack/scenes/Content/Details/ContentInfo.js