Sha256: c91ff90415ae71b8ebf6e5a10a88fa42c49647a49fa39f2eea0bfbe19aeae0b2

Contents?: true

Size: 1.43 KB

Versions: 61

Compression:

Stored size: 1.43 KB

Contents

import { selectForemanTasks } from '../../../../ForemanTasksSelectors';
import {
  selectTasksTableQuery,
  selectResults,
  selectSelectedRows,
  selectItemCount,
  selectAllRowsSelected,
} from '../../TasksTableSelectors';
import { RESUME_MODAL, CANCEL_MODAL } from '../../TasksTableConstants';
import { FORCE_UNLOCK_MODAL } from '../../../TaskActions/TaskActionsConstants';

export const selectCofirmModal = state =>
  selectForemanTasks(state).confirmModal || {};

export const selectActionType = state => selectCofirmModal(state).actionType;
export const selectActionText = state => selectCofirmModal(state).actionText;
export const selectActionState = state => selectCofirmModal(state).actionState;
export const selectClicked = state =>
  selectTasksTableQuery(state).clicked || {};

export const selectSelectedTasks = state => {
  const selectedIDs = selectResults(state).filter(item =>
    selectSelectedRows(state).includes(item.id)
  );
  return selectedIDs.map(item => ({
    name: item.action,
    id: item.id,
    isCancellable: item.availableActions.cancellable,
    isResumable: item.availableActions.resumable,
    canEdit: item.canEdit,
  }));
};

export const selectSelectedRowsLen = state => {
  if (
    [CANCEL_MODAL, RESUME_MODAL, FORCE_UNLOCK_MODAL].includes(
      selectActionType(state)
    )
  ) {
    return 1;
  }
  if (selectAllRowsSelected(state)) {
    return selectItemCount(state);
  }
  return selectSelectedRows(state).length;
};

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
foreman-tasks-10.0.1 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-10.0.0 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-9.2.3 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-9.2.2 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-9.2.1 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-9.2.0 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-9.1.1 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-9.0.4 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-9.1.0 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-9.0.2 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-9.0.1 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-8.3.3 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-9.0.0 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-8.2.1 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-8.1.4 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-8.3.2 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-8.3.1 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-8.1.3 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-8.3.0 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
foreman-tasks-8.2.0 webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js