Sha256: 508ae1f63fd1497bc0ec90ecaad7fc8c7ff0d9c278a9d2de210fa3e64d121022

Contents?: true

Size: 1.46 KB

Versions: 16

Compression:

Stored size: 1.46 KB

Contents

import Immutable from 'seamless-immutable';
import {
  FOREMAN_TASK_DETAILS_FETCH_TASK_REQUEST,
  FOREMAN_TASK_DETAILS_FETCH_TASK_SUCCESS,
  FOREMAN_TASK_DETAILS_STOP_POLLING,
  FOREMAN_TASK_DETAILS_START_POLLING,
  FOREMAN_TASK_DETAILS_TOGGLE_UNLOCK_MODAL,
  FOREMAN_TASK_DETAILS_TOGGLE_FORCE_UNLOCK_MODAL,
} from './TaskDetailsConstants';

const initialState = Immutable({});

export default (state = initialState, action) => {
  const { type, payload } = action;
  let { taskReload, timeoutId } = state;

  switch (type) {
    case FOREMAN_TASK_DETAILS_FETCH_TASK_REQUEST:
      return state.set('loading', true);
    case FOREMAN_TASK_DETAILS_FETCH_TASK_SUCCESS:
      if (payload.state === 'stopped') {
        clearTimeout(state.timeoutId);
        taskReload = false;
        timeoutId = null;
      }
      return state.merge({
        loading: false,
        ...payload,
        taskReload,
        timeoutId,
      });
    case FOREMAN_TASK_DETAILS_STOP_POLLING:
      return state.merge({ taskReload: false, timeoutId: null });
    case FOREMAN_TASK_DETAILS_START_POLLING:
      clearTimeout(state.timeoutId);
      return state.merge({ taskReload: true, timeoutId: payload.timeoutId });
    case FOREMAN_TASK_DETAILS_TOGGLE_UNLOCK_MODAL:
      return state.set('showUnlockModal', !state.showUnlockModal);
    case FOREMAN_TASK_DETAILS_TOGGLE_FORCE_UNLOCK_MODAL:
      return state.set('showForceUnlockModal', !state.showForceUnlockModal);
    default:
      return state;
  }
};

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
foreman-tasks-1.1.3 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-1.1.2 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-1.1.1 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-1.1.0 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-0.17.6 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-1.0.1 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-1.0.0 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-0.17.5 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-0.17.4 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-0.17.3 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-0.17.2 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-0.16.3 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-0.17.1 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-0.16.2 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-0.16.1 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js
foreman-tasks-0.17.0 webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js