Sha256: fdc2ae4188d59ed5c9c40b9a7b0637f71e7948ce92de934256b5c612573d9ae4

Contents?: true

Size: 1.56 KB

Versions: 147

Compression:

Stored size: 1.56 KB

Contents

import Immutable from 'seamless-immutable';

import {
  INVENTORY_POLLING_START,
  INVENTORY_POLLING,
  INVENTORY_TAB_CHANGED,
  INVENTORY_POLLING_ERROR,
  INVENTORY_TOGGLE_TERMINAL_FULL_SCREEN,
} from './DashboardConstants';

const initialState = Immutable({});

export default (state = initialState, action) => {
  const {
    payload: {
      accountID,
      pollingProcessID,
      logs,
      error,
      activeTab,
      scheduled,
    } = {},
  } = action;

  const getTabState = () =>
    state[accountID] ? state[accountID][activeTab] : {};
  switch (action.type) {
    case INVENTORY_POLLING_START:
      return state.setIn([accountID], {
        ...state[accountID],
        pollingProcessID,
        activeTab: 'generating',
      });
    case INVENTORY_POLLING:
      return state.setIn([accountID], {
        ...state[accountID],
        [activeTab]: {
          ...getTabState(),
          logs,
          scheduled,
          error: null,
        },
      });
    case INVENTORY_TAB_CHANGED:
      return state.setIn([accountID], {
        ...state[accountID],
        activeTab,
      });
    case INVENTORY_POLLING_ERROR:
      return state.setIn([accountID], {
        ...state[accountID],
        [activeTab]: {
          ...getTabState(),
          error,
        },
      });
    case INVENTORY_TOGGLE_TERMINAL_FULL_SCREEN:
      return state.setIn([accountID], {
        ...state[accountID],
        [activeTab]: {
          ...getTabState(),
          showFullScreen: !state[accountID][activeTab].showFullScreen,
        },
      });
    default:
      return state;
  }
};

Version data entries

147 entries across 147 versions & 2 rubygems

Version Path
foreman_rh_cloud-5.0.38 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-4.0.35 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-5.0.37 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-5.0.36 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-5.0.35 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-5.0.34 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-5.0.33 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-3.0.32 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-4.0.32 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-5.0.32 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-4.0.31 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-5.0.31 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-5.0.30 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-4.0.30 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-3.0.29 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-4.0.29 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-5.0.29 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-3.0.28 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-5.0.28 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-4.0.27 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js