Sha256: 658930d797d3a1a9f91b0f375b9ab22c429f2c8245b40bda6565d7e4288477a1

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

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

import {
  ENABLED_REPOSITORIES_REQUEST,
  ENABLED_REPOSITORIES_SUCCESS,
  ENABLED_REPOSITORIES_FAILURE,
  REPOSITORY_DISABLED,
} from '../../consts';
import { propsToSnakeCase } from '../../../services/index';

export const setRepositoryDisabled = repository => ({
  type: REPOSITORY_DISABLED,
  repository,
});

export const createEnabledRepoParams = (extendedParams = {}) => {
  const searchParams = extendedParams.search || {};
  const search = joinSearchQueries([
    'redhat = true',
    repoTypeFilterToSearchQuery(searchParams.filters || []),
    searchParams.query,
  ]);

  const repoParams = {
    ...{ organization_id: orgId, enabled: 'true' },
    ...propsToSnakeCase(extendedParams),
    search,
  };

  return { searchParams, repoParams };
};

export const loadEnabledRepos = (extendedParams = {}) => (dispatch) => {
  dispatch({ type: ENABLED_REPOSITORIES_REQUEST, params: extendedParams });
  const { searchParams, repoParams } = createEnabledRepoParams(extendedParams);

  api
    .get('/repositories', {}, repoParams)
    .then(({ data }) => {
      dispatch({
        type: ENABLED_REPOSITORIES_SUCCESS,
        response: normalizeRepositorySets(data),
        search: searchParams,
      });
    })
    .catch((result) => {
      dispatch({
        type: ENABLED_REPOSITORIES_FAILURE,
        result,
      });
    });
};

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katello-3.7.0.rc1 webpack/redux/actions/RedHatRepositories/enabled.js