Sha256: 3f0026a61ae1372880548e32fc2ef71826aa445f2932b565bf5d6adabda0c808

Contents?: true

Size: 1.94 KB

Versions: 16

Compression:

Stored size: 1.94 KB

Contents

import { createSelector } from 'reselect';
import { translate as __ } from 'foremanReact/common/I18n';
import { selectForemanTasks } from '../../ForemanTasksSelectors';
import { getDuration } from './TasksTableHelpers';

export const selectTasksTable = state =>
  selectForemanTasks(state).tasksTable || {};

export const selectTasksTableContent = state =>
  selectTasksTable(state).tasksTableContent || {};

export const selectTasksTableQuery = state =>
  selectTasksTable(state).tasksTableQuery || {};

export const selectPagitation = state =>
  selectTasksTableQuery(state).pagination || {};

export const selectItemCount = state =>
  selectTasksTableQuery(state).itemCount || 0;

export const selectActionName = state =>
  selectTasksTableQuery(state).actionName || '';

export const selectSelectedRows = state =>
  selectTasksTableQuery(state).selectedRows || [];

export const selectResults = createSelector(
  selectTasksTableContent,
  ({ results }) =>
    results.map(result => ({
      ...result,
      action:
        result.action ||
        (result.label ? result.label.replace(/::/g, ' ') : result.id),
      username: result.username || '',
      state: result.state + (result.frozen ? ` ${__('Disabled')}` : ''),
      duration: getDuration(result.started_at, result.ended_at),
      availableActions: {
        ...result.available_actions,
        stoppable: result.state !== 'stopped',
      },
      canEdit: result.can_edit,
    }))
);

export const selectStatus = state => selectTasksTableContent(state).status;

export const selectError = state => selectTasksTableContent(state).error;

export const selectSort = state =>
  selectTasksTableQuery(state).sort || { by: 'started_at', order: 'DESC' };

export const selectAllRowsSelected = state =>
  selectTasksTableQuery(state).allRowsSelected;

export const selectShowSelectAll = state =>
  selectTasksTableQuery(state).showSelectAll;

export const selectModalID = state =>
  selectTasksTableQuery(state).modalID || '';

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
foreman-tasks-4.1.3 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-3.0.6 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-5.0.0 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-4.1.2 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-4.1.1 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-4.0.1 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-4.1.0 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-3.0.5 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-4.0.0 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-3.0.4 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-2.0.3 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-3.0.3 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-3.0.2 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-3.0.1 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-3.0.0 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-2.0.2 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js