Sha256: 28f3a933be5f625ad5d2f207796b491d187f4a47ee3ff64f926939c68e144624

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

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

import {
  enabledCellFormatter,
  nameToEditFormatter,
  actionCellFormatter,
} from './Components/Formatters';

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

const createWebhooksTableSchema = (
  apiCall,
  by,
  order,
  webhookActions,
  onEditClick
) => {
  const sortController = sortControllerFactory(apiCall, by, order);

  return [
    sortableColumn('name', __('Name'), 4, sortController, [
      nameToEditFormatter('webhooks', onEditClick),
    ]),
    sortableColumn('targetUrl', __('Target URL'), 4, sortController),
    sortableColumn('enabled', __('Enabled'), 2, sortController, [
      enabledCellFormatter(),
    ]),
    column(
      'actions',
      __('Actions'),
      [headerFormatterWithProps],
      [actionCellFormatter(webhookActions)]
    ),
  ];
};

export default createWebhooksTableSchema;

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_webhooks-4.0.0 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTableSchema.js
foreman_webhooks-3.2.3 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTableSchema.js
foreman_webhooks-3.2.2 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTableSchema.js
foreman_webhooks-3.2.1 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTableSchema.js
foreman_webhooks-3.2.0 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTableSchema.js