Sha256: 4888dec2d18b9f90b7b95aacf64f5f71bebc139bf802a4462efc97335417abcf

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 KB

Contents

import Immutable from 'seamless-immutable';
import {
  INVENTORY_ACCOUNT_STATUS_POLLING,
  INVENTORY_ACCOUNT_STATUS_POLLING_ERROR,
  INVENTORY_ACCOUNT_STATUS_POLLING_START,
  INVENTORY_PROCESS_RESTART,
} from './AccountListConstants';

const initialState = Immutable({
  statuses: {},
  pollingProcessID: 0,
  error: null,
});

export default (state = initialState, action) => {
  const {
    payload: {
      pollingProcessID,
      error,
      statuses,
      accountID,
      processStatusName,
    } = {},
  } = action;

  switch (action.type) {
    case INVENTORY_ACCOUNT_STATUS_POLLING:
      return state.merge({
        ...state,
        statuses,
        error: null,
      });
    case INVENTORY_ACCOUNT_STATUS_POLLING_ERROR:
      return state.merge({
        ...state,
        statuses: {},
        error,
      });
    case INVENTORY_ACCOUNT_STATUS_POLLING_START:
      return state.merge({
        ...state,
        pollingProcessID,
      });
    case INVENTORY_PROCESS_RESTART:
      return state.setIn(['statuses'], {
        ...state.statuses,
        [accountID]: {
          ...state.statuses[accountID],
          [processStatusName]: 'Restarting...',
        },
      });
    default:
      return state;
  }
};

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
foreman_inventory_upload-1.0.0.beta7 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-1.0.0.beta6 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-1.0.0.beta5 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-1.0.0.beta4 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-1.0.0.beta3 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-1.0.0.beta2 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js