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-9.0.59 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-11.0.2 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-11.0.1 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-11.0.0 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-9.0.58 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-10.0.2 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-9.0.57 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-10.0.1 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-9.0.56 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-9.0.55 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-9.0.54 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-9.0.53 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-9.0.52 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-8.0.52 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-9.0.51 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-8.0.51 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-7.0.48 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-7.0.47 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-8.0.50 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
foreman_rh_cloud-8.0.49 webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js