Sha256: e9a95aa5fdb58735ac20279ecea0239bab0caa93d94403a4cf5223edd9bb70ef

Contents?: true

Size: 1.54 KB

Versions: 66

Compression:

Stored size: 1.54 KB

Contents

import { initialApiState } from '../../../services/api';

import {
  UPSTREAM_SUBSCRIPTIONS_REQUEST,
  UPSTREAM_SUBSCRIPTIONS_SUCCESS,
  UPSTREAM_SUBSCRIPTIONS_FAILURE,
  SAVE_UPSTREAM_SUBSCRIPTIONS_REQUEST,
  SAVE_UPSTREAM_SUBSCRIPTIONS_SUCCESS,
  SAVE_UPSTREAM_SUBSCRIPTIONS_FAILURE,
} from './UpstreamSubscriptionsConstants';

const initialState = initialApiState;

export default (state = initialState, action) => {
  switch (action.type) {
    case UPSTREAM_SUBSCRIPTIONS_REQUEST:
      return state.set('loading', true);

    case UPSTREAM_SUBSCRIPTIONS_SUCCESS: {
      const {
        page, per_page, total, results, // eslint-disable-line camelcase

      } = action.response;

      return state.merge({
        results,
        loading: false,
        searchIsActive: !!action.search,
        search: action.search,
        pagination: {
          page: Number(page),
          // eslint-disable-next-line camelcase
          perPage: Number(per_page || state.pagination.perPage),
        },
        itemCount: Number(total),
      });
    }

    case UPSTREAM_SUBSCRIPTIONS_FAILURE:
      return state.merge({
        error: action.payload.message,
        loading: false,
      });

    case SAVE_UPSTREAM_SUBSCRIPTIONS_REQUEST:
      return state.set('loading', true);

    case SAVE_UPSTREAM_SUBSCRIPTIONS_SUCCESS:
      return state.set('task', action.response).set('loading', false);

    case SAVE_UPSTREAM_SUBSCRIPTIONS_FAILURE: {
      return state.set('error', action.payload.message).set('loading', false);
    }

    default:
      return state;
  }
};

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
katello-4.3.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.4.0.rc1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.2.2 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.3.0 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.3.0.rc4 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.3.0.rc3 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.3.0.rc2.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.3.0.rc2 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.3.0.rc1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.2.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.2.0.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.1.4 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.0.3 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.2.0.1.rc3 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-3.18.5 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.2.0.1.rc2 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.2.0.rc2 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.1.3 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.2.0.rc1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.0.2.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js