Sha256: f43d3b80bfb27cf299f55e22e4bbfb3d76a38c010ad3399c45bd2450c7a1de6d

Contents?: true

Size: 1.7 KB

Versions: 11

Compression:

Stored size: 1.7 KB

Contents

import api, { orgId } from '../../../services/api';
import {
  normalizeRepositorySets,
  repoTypeFilterToSearchQuery,
  joinSearchQueries,
  recommendedRepositorySetsQuery,
} from './helpers';

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

// eslint-disable-next-line import/prefer-default-export
export const loadRepositorySets = (extendedParams = {}) => (dispatch, getState) => {
  const { recommended } = getState().katello.redHatRepositories.sets;

  dispatch({ type: REPOSITORY_SETS_REQUEST, params: extendedParams });

  const searchParams = extendedParams.search || {};
  const search = joinSearchQueries([
    repoTypeFilterToSearchQuery(searchParams.filters || []),
    searchParams.query,
    recommended ? recommendedRepositorySetsQuery : '',
  ]);

  const params = {
    ...{ organization_id: orgId(), with_active_subscription: true },
    ...propsToSnakeCase(extendedParams),
    search,
  };

  api
    .get('/repository_sets', {}, params)
    .then(({ data }) => {
      dispatch({
        type: REPOSITORY_SETS_SUCCESS,
        payload: {
          response: normalizeRepositorySets(data),
          search: searchParams,
        },
      });
    })
    .catch((result) => {
      dispatch({
        type: REPOSITORY_SETS_FAILURE,
        payload: result,
      });
    });
};

export const updateRecommendedRepositorySets = value => (dispatch, getState) => {
  const { search } = getState().katello.redHatRepositories.sets;

  dispatch({
    type: REPOSITORY_SETS_UPDATE_RECOMMENDED,
    payload: value,
  });

  dispatch(loadRepositorySets({ search }));
};

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
katello-3.9.1 webpack/redux/actions/RedHatRepositories/sets.js
katello-3.9.0 webpack/redux/actions/RedHatRepositories/sets.js
katello-3.8.1 webpack/redux/actions/RedHatRepositories/sets.js
katello-3.9.0.rc2 webpack/redux/actions/RedHatRepositories/sets.js
katello-3.9.0.rc1 webpack/redux/actions/RedHatRepositories/sets.js
katello-3.7.1.1 webpack/redux/actions/RedHatRepositories/sets.js
katello-3.7.1 webpack/redux/actions/RedHatRepositories/sets.js
katello-3.8.0 webpack/redux/actions/RedHatRepositories/sets.js
katello-3.8.0.rc3 webpack/redux/actions/RedHatRepositories/sets.js
katello-3.8.0.rc2 webpack/redux/actions/RedHatRepositories/sets.js
katello-3.7.0 webpack/redux/actions/RedHatRepositories/sets.js