Sha256: b7ac2dca66b054ec276e3c556353ce434f781e1a7f2f128799f8dbe3d2dbeef5

Contents?: true

Size: 1.29 KB

Versions: 33

Compression:

Stored size: 1.29 KB

Contents

/* eslint-disable camelcase */
import { columns } from './InsightsTableConstants';

export const modifySelectedRows = (hits, selectedIds, showSelectAllAlert) => {
  if (hits.length === 0) return [];

  return hits
    .asMutable()
    .map(({ id, hostname, title, total_risk, has_playbook }) => {
      const disableCheckbox = !has_playbook;
      return {
        cells: [hostname, title, total_risk, has_playbook],
        disableCheckbox,
        id,
        /** The main table checkbox will be seen as selected only if all rows are selected,
         * in this case we need to select also the disabled once and hide it with css */
        selected: selectedIds[id] || (disableCheckbox && showSelectAllAlert),
      };
    });
};

export const getSortColumnIndex = sortBy => {
  let colIndex = 0;
  columns.forEach((col, index) => {
    if (col.sortKey === sortBy) {
      // The checkbox column shifts the data columns by 1;
      colIndex = index + 1;
    }
  });
  return colIndex;
};

export const getPerPageOptions = (urlPerPage, appPerPage) => {
  const initialValues = new Set([5, 10, 15, 25, 50]);
  initialValues.add(appPerPage);
  urlPerPage && initialValues.add(urlPerPage);
  const options = [...initialValues].sort((a, b) => a - b);
  return options.map(value => ({ title: value.toString(), value }));
};

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.36 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-3.0.33 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-4.0.35 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-3.0.32 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-4.0.32 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-4.0.31 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-4.0.30 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-3.0.29 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-4.0.29 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-3.0.28 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-5.0.28 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-4.0.27 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-3.0.26 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-4.0.26 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-4.0.25.1 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-3.0.25 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-4.0.25 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-3.0.24.1 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-4.0.24.1 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js
foreman_rh_cloud-3.0.24 webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js