Sha256: dc4a2e8ebc239db891336cf7ec2131d47dc38666cd4ef12fac1408ea8ca86032

Contents?: true

Size: 1.47 KB

Versions: 65

Compression:

Stored size: 1.47 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

65 entries across 65 versions & 1 rubygems

Version Path
katello-4.14.3 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.14.2 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.15.0 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.15.0.rc2 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.15.0.rc1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.14.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.14.0 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.14.0.rc3 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.14.0.rc2 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.14.0.rc1.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.14.0.rc1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.13.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.13.0 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.12.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.13.0.rc1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.12.0 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.12.0.rc3 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.12.0.rc2 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.12.0.rc1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js
katello-4.11.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js