Sha256: 7237e9d5d32922369d726857ff86b3519ec6e6f272bebb54b221cbd6b0e6325f

Contents?: true

Size: 1.21 KB

Versions: 15

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({
  accounts: {},
  pollingProcessID: 0,
  error: null,
});

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

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

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
foreman_rh_cloud-0.9.4.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_rh_cloud-1.0.4.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_rh_cloud-1.0.4 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_rh_cloud-2.0.4 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_rh_cloud-0.9.4 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-2.0.4.pre.2 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-2.0.4.pre.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-2.0.3 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-1.0.3 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-0.9.2 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-1.0.2 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-0.9.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-1.0.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-0.9.0 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_inventory_upload-1.0.0 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js