Sha256: 998458b2f0e08592372cfd748ed67e95903b141c334afd4fdd7d59a9c1c9c031

Contents?: true

Size: 1.49 KB

Versions: 5

Compression:

Stored size: 1.49 KB

Contents

import { translate as __ } from 'foremanReact/common/I18n';
import {
  column,
  sortableColumn,
  headerFormatterWithProps,
  deleteActionCellFormatter,
  cellFormatter,
} from 'foremanReact/components/common/table';

import {
  formatCellFormatter,
  reportToShowFormatter,
  hostReportsToShowFormatter,
  statusFormatter,
} from './Components/Formatters';

const sortControllerFactory = (apiCall, sortBy, sortOrder) => ({
  apply: (by, order) => {
    apiCall({ sort: { by, order } });
  },
  property: sortBy,
  order: sortOrder,
});

const createHostReportsTableSchema = (
  apiCall,
  by,
  order,
  onDeleteClick,
  hostId
) => {
  const sortController = sortControllerFactory(apiCall, by, order);
  const hostColumn = hostId
    ? []
    : [
        sortableColumn('hostName', __('Host'), 3, sortController, [
          hostReportsToShowFormatter(),
        ]),
      ];

  return hostColumn.concat([
    sortableColumn('reportedAt', __('Last report'), 1, sortController, [
      reportToShowFormatter(),
    ]),
    sortableColumn('format', __('Format'), 1, sortController, [
      formatCellFormatter(),
    ]),
    column(
      'status',
      __('Overall status'),
      [headerFormatterWithProps],
      [statusFormatter()],
      { className: `col-lg-auto` }
    ),
    column(
      'actions',
      __('Actions'),
      [headerFormatterWithProps],
      [deleteActionCellFormatter(onDeleteClick), cellFormatter],
      { className: `col-md-1` }
    ),
  ]);
};

export default createHostReportsTableSchema;

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_host_reports-1.0.2 webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/HostReportsTableSchema.js
foreman_host_reports-1.0.1 webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/HostReportsTableSchema.js
foreman_host_reports-1.0.0 webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/HostReportsTableSchema.js
foreman_host_reports-0.0.4 webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/HostReportsTableSchema.js
foreman_host_reports-0.0.3 webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/HostReportsTableSchema.js