Sha256: 8febf5eeeca950e80301a97964a01989d0906ffaf21e0a25fcc5a5330884c25e

Contents?: true

Size: 1.66 KB

Versions: 5

Compression:

Stored size: 1.66 KB

Contents

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

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 selectModalStatus = state =>
  selectTasksTableQuery(state).modalStatus || CLOSED;

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

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' };

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman-tasks-0.17.6 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-1.0.0 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-0.17.5 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-0.17.4 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js
foreman-tasks-0.17.3 webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js