Sha256: 93c84e74a5a5648ab111dae44f2e1521ecd982cfda601bfbab28464db8e0dada

Contents?: true

Size: 1.54 KB

Versions: 17

Compression:

Stored size: 1.54 KB

Contents

import React from 'react';
import PropTypes from 'prop-types';
import { useDispatch, useSelector } from 'react-redux';
import {
  Pagination as PfPagination,
  PaginationVariant,
} from '@patternfly/react-core';
import { useForemanSettings } from 'foremanReact/Root/Context/ForemanContext';
import { onTablePerPageSelect, onTableSetPage } from './InsightsTableActions';
import { getPerPageOptions } from './InsightsTableHelpers';
import {
  selectItemCount,
  selectPage,
  selectPerPage,
} from './InsightsTableSelectors';

const Pagination = ({ variant, ...props }) => {
  const dispatch = useDispatch();
  const onSetPage = (e, pageNumber) => dispatch(onTableSetPage(e, pageNumber));
  const onPerPageSelect = (e, perPageNumber) =>
    dispatch(onTablePerPageSelect(e, perPageNumber));
  const itemCount = useSelector(state => selectItemCount(state));
  const urlPerPage = useSelector(state => selectPerPage(state));
  const page = useSelector(state => selectPage(state));
  const { perPage: appPerPage } = useForemanSettings();
  const perPage = urlPerPage || appPerPage;

  return (
    <PfPagination
      itemCount={itemCount}
      widgetId={`recommendation-pagination-${variant}`}
      perPage={perPage}
      page={page}
      variant={PaginationVariant[variant]}
      onSetPage={onSetPage}
      onPerPageSelect={onPerPageSelect}
      perPageOptions={getPerPageOptions(urlPerPage, appPerPage)}
      {...props}
    />
  );
};

Pagination.propTypes = {
  variant: PropTypes.string,
};

Pagination.defaultProps = {
  variant: 'top',
};

export default Pagination;

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.36 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-4.0.35 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-5.0.35 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-5.0.34 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-5.0.33 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-4.0.32 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-5.0.32 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-4.0.31 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-5.0.31 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-5.0.30 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-4.0.30 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-4.0.29 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-5.0.29 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-5.0.28 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-4.0.27 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-4.0.26 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js
foreman_rh_cloud-4.0.25.1 webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js