Sha256: fc8579c9e77f95860140a53410e88a778c748b15a238a92363428a24ebdd0a5a

Contents?: true

Size: 1.55 KB

Versions: 76

Compression:

Stored size: 1.55 KB

Contents

import Immutable from 'seamless-immutable';
import {
  TASKS_DASHBOARD_AVAILABLE_TIMES,
  FOREMAN_TASKS_DASHBOARD_INIT,
  FOREMAN_TASKS_DASHBOARD_UPDATE_TIME,
  FOREMAN_TASKS_DASHBOARD_UPDATE_QUERY,
  FOREMAN_TASKS_DASHBOARD_FETCH_TASKS_SUMMARY_REQUEST,
  FOREMAN_TASKS_DASHBOARD_FETCH_TASKS_SUMMARY_SUCCESS,
  FOREMAN_TASKS_DASHBOARD_FETCH_TASKS_SUMMARY_FAILURE,
  TASKS_SUMMARY_ZERO,
} from './TasksDashboardConstants';

const initialState = Immutable({
  time: TASKS_DASHBOARD_AVAILABLE_TIMES.H24,
  isLoadingTasksSummary: false,
  error: null,
  tasksSummary: TASKS_SUMMARY_ZERO,
});

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

  switch (type) {
    case FOREMAN_TASKS_DASHBOARD_INIT:
      return state
        .set('time', (payload && payload.time) || initialState.time)
        .set('query', (payload && payload.query) || initialState.query);
    case FOREMAN_TASKS_DASHBOARD_UPDATE_TIME:
      return state.set('time', payload);
    case FOREMAN_TASKS_DASHBOARD_UPDATE_QUERY:
      return state.set('query', payload);
    case FOREMAN_TASKS_DASHBOARD_FETCH_TASKS_SUMMARY_REQUEST:
      return state.set('isLoading', true);
    case FOREMAN_TASKS_DASHBOARD_FETCH_TASKS_SUMMARY_SUCCESS:
      return state.merge({
        tasksSummary: payload,
        isLoading: false,
        error: null,
      });
    case FOREMAN_TASKS_DASHBOARD_FETCH_TASKS_SUMMARY_FAILURE:
      return state.merge({
        tasksSummary: TASKS_SUMMARY_ZERO,
        isLoading: false,
        error: payload,
      });
    default:
      return state;
  }
};

Version data entries

76 entries across 76 versions & 1 rubygems

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