Sha256: 8f364662dd2da56338051c710406b5660ca93ccbe7989a6c8a9fb3cb5be7aafb

Contents?: true

Size: 1.37 KB

Versions: 65

Compression:

Stored size: 1.37 KB

Contents

import { addToast } from 'foremanReact/redux/actions/toasts';
import { propsToSnakeCase } from 'foremanReact/common/helpers';
import { get } from 'foremanReact/redux/API';
import { stopInterval, withInterval } from 'foremanReact/redux/middlewares/IntervalMiddleware';
import { foremanTasksApi } from '../../services/api';
import { bulkSearchKey, pollTaskKey, taskFinishedToast } from './helpers';

export const toastTaskFinished = task => async (dispatch) => {
  dispatch(addToast(taskFinishedToast(task)));
};

const taskBulkSearchParams = params => ({
  search: Object.entries(propsToSnakeCase(params))
    .map((item) => {
      if (item[0] === 'action') {
        return `${item[0]}~${item[1]}`;
      }
      return `${item[0]}=${item[1]}`;
    })
    .join(' and '),
});

const getTasks = (key, params = {}) => get({
  key,
  url: `${foremanTasksApi.baseApiPath}/tasks`,
  params: taskBulkSearchParams(params),
});

export const startPollingTasks = (key, taskSearchParams = {}) =>
  withInterval(getTasks(bulkSearchKey(key), taskSearchParams));

export const stopPollingTasks = key => stopInterval(bulkSearchKey(key));

const getTask = (key, task) => get({
  key,
  url: `${foremanTasksApi.baseApiPath}/tasks/${task.id}`,
});

export const startPollingTask = (key, task) =>
  withInterval(getTask(pollTaskKey(key), task));

export const stopPollingTask = key => stopInterval(pollTaskKey(key));

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
katello-4.2.2 webpack/scenes/Tasks/TaskActions.js
katello-4.3.0.rc3 webpack/scenes/Tasks/TaskActions.js
katello-4.3.0.rc2.1 webpack/scenes/Tasks/TaskActions.js
katello-4.3.0.rc2 webpack/scenes/Tasks/TaskActions.js
katello-4.3.0.rc1 webpack/scenes/Tasks/TaskActions.js
katello-4.2.1 webpack/scenes/Tasks/TaskActions.js
katello-4.2.0.1 webpack/scenes/Tasks/TaskActions.js
katello-4.1.4 webpack/scenes/Tasks/TaskActions.js
katello-4.0.3 webpack/scenes/Tasks/TaskActions.js
katello-4.2.0.1.rc3 webpack/scenes/Tasks/TaskActions.js
katello-3.18.5 webpack/scenes/Tasks/TaskActions.js
katello-4.2.0.1.rc2 webpack/scenes/Tasks/TaskActions.js
katello-4.2.0.rc2 webpack/scenes/Tasks/TaskActions.js
katello-4.1.3 webpack/scenes/Tasks/TaskActions.js
katello-4.2.0.rc1 webpack/scenes/Tasks/TaskActions.js
katello-4.0.2.1 webpack/scenes/Tasks/TaskActions.js
katello-4.1.2.1 webpack/scenes/Tasks/TaskActions.js
katello-4.0.2 webpack/scenes/Tasks/TaskActions.js
katello-4.1.2 webpack/scenes/Tasks/TaskActions.js
katello-3.18.4 webpack/scenes/Tasks/TaskActions.js