Sha256: 7395e1bf1bd8ac52a267758053839f65a745253c19ae26de4125a7c1a06bb82d

Contents?: true

Size: 1.77 KB

Versions: 9

Compression:

Stored size: 1.77 KB

Contents

import Immutable from 'seamless-immutable';
import { AUTO_UPLOAD_TOGGLE } from '../AutoUploadSwitcher/AutoUploadSwitcherConstants';
import { HOST_OBFUSCATION_TOGGLE } from '../HostObfuscationSwitcher/HostObfuscationSwitcherConstants';
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,
      autoUploadEnabled,
      hostObfuscationEnabled,
      cloudToken,
    } = {},
  } = action;

  switch (action.type) {
    case INVENTORY_ACCOUNT_STATUS_POLLING:
      return state.merge({
        ...state,
        accounts,
        autoUploadEnabled,
        hostObfuscationEnabled,
        cloudToken,
        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...',
        },
      });
    case AUTO_UPLOAD_TOGGLE:
      return state.merge({
        ...state,
        autoUploadEnabled,
      });
    case HOST_OBFUSCATION_TOGGLE:
      return state.merge({
        ...state,
        hostObfuscationEnabled,
      });
    default:
      return state;
  }
};

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
foreman_rh_cloud-0.9.12 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_rh_cloud-1.0.12 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_rh_cloud-2.0.12 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_rh_cloud-0.9.11 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_rh_cloud-1.0.11 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_rh_cloud-2.0.11 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_rh_cloud-0.9.10 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_rh_cloud-1.0.10 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js
foreman_rh_cloud-2.0.10 webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js