Sha256: fb108a5545bc67b3f5e931b4a162663db1d758edb84dc1d0e2f0e8567d0fac98

Contents?: true

Size: 1.33 KB

Versions: 38

Compression:

Stored size: 1.33 KB

Contents

import Immutable from 'seamless-immutable';
import { isEmpty } from 'lodash';

import {
  REPOSITORY_SETS_REQUEST,
  REPOSITORY_SETS_SUCCESS,
  REPOSITORY_SETS_FAILURE,
  REPOSITORY_SETS_UPDATE_RECOMMENDED,
} from '../../consts';

import { initialState } from './sets.fixtures.js';

export default (state = initialState, action) => {
  const { payload } = action;

  switch (action.type) {
    case REPOSITORY_SETS_REQUEST:
      return state.set('loading', true);

    case REPOSITORY_SETS_UPDATE_RECOMMENDED:
      return state
        .set('recommended', payload);

    case REPOSITORY_SETS_SUCCESS:
      return state
        .set('results', payload.response.results)
        .set('pagination', {
          page: Number(payload.response.page),
          // server can return per_page: null when there's error in the search query,
          // don't store it in such case
          // eslint-disable-next-line camelcase
          perPage: Number(payload.response.per_page || state.pagination.perPage),
        })
        .set('itemCount', Number(payload.response.subtotal))
        .set('loading', false)
        .set('searchIsActive', !isEmpty(payload.search))
        .set('search', payload.search);

    case REPOSITORY_SETS_FAILURE:
      return Immutable({
        error: payload,
        loading: false,
      });

    default:
      return state;
  }
};

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
katello-3.13.4 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.13.3 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.13.2 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.13.1 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.13.0 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.13.0.rc2.1 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.13.0.rc2 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.12.3 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.12.2 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.13.0.rc1 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.12.1 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.11.2 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.10.2 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.12.0 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.12.0.rc2 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.10.1.1 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.12.0.rc1 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.10.1 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.11.1 webpack/redux/reducers/RedHatRepositories/sets.js
katello-3.11.0 webpack/redux/reducers/RedHatRepositories/sets.js