webpack/redux/actions/RedHatRepositories/enabled.js in katello-3.13.4 vs webpack/redux/actions/RedHatRepositories/enabled.js in katello-3.14.0.rc1
- old
+ new
@@ -1,7 +1,7 @@
import { propsToSnakeCase } from 'foremanReact/common/helpers';
-
+import { get } from 'lodash';
import api, { orgId } from '../../../services/api';
import {
normalizeRepositorySets,
repoTypeFilterToSearchQuery,
productsIdsToSearchQuery,
@@ -32,54 +32,54 @@
productsIdsToSearchQuery(searchParams.products || []),
searchParams.query,
]);
const repoParams = {
- ...{ organization_id: orgId(), enabled: 'true' },
+ ...{ organization_id: orgId(), enabled: 'true', include_permissions: 'true' },
...propsToSnakeCase(extendedParams),
search,
};
return { searchParams, repoParams };
};
-export const disableRepository = repository => (dispatch) => {
+export const disableRepository = repository => async (dispatch) => {
const {
productId, contentId, arch, releasever,
} = repository;
const repoData = {
id: contentId,
product_id: productId,
basearch: arch,
releasever,
};
-
dispatch({ type: DISABLE_REPOSITORY_REQUEST, repository });
-
const url = `/products/${productId}/repository_sets/${contentId}/disable`;
- return api
- .put(url, repoData)
- .then(result => dispatch(apiSuccess(DISABLE_REPOSITORY_SUCCESS, result)))
- .catch(result => dispatch(apiError(DISABLE_REPOSITORY_FAILURE, result, { repository })));
+ try {
+ const result = await api.put(url, repoData);
+ return dispatch(apiSuccess(DISABLE_REPOSITORY_SUCCESS, result));
+ } catch (error) {
+ return dispatch(apiError(DISABLE_REPOSITORY_FAILURE, error, { repository }));
+ }
};
-export const loadEnabledRepos = (extendedParams = {}, silent = false) => (dispatch) => {
+export const loadEnabledRepos = (extendedParams = {}, silent = false) => async (dispatch) => {
dispatch({ type: ENABLED_REPOSITORIES_REQUEST, params: extendedParams, silent });
const { searchParams, repoParams } = createEnabledRepoParams(extendedParams);
- return api
- .get('/repositories', {}, repoParams)
- .then(({ data }) => {
- dispatch({
- type: ENABLED_REPOSITORIES_SUCCESS,
- response: normalizeRepositorySets(data),
- search: searchParams,
- });
- })
- .catch((result) => {
- dispatch({
- type: ENABLED_REPOSITORIES_FAILURE,
- result,
- });
+ try {
+ const { data } = await api.get('/repositories', {}, repoParams);
+ return dispatch({
+ type: ENABLED_REPOSITORIES_SUCCESS,
+ response: normalizeRepositorySets(data),
+ search: searchParams,
});
+ } catch (error) {
+ const missingPermissions = get(error, ['response', 'data', 'error', 'missing_permissions']);
+ return dispatch({
+ type: ENABLED_REPOSITORIES_FAILURE,
+ result: error,
+ missingPermissions,
+ });
+ }
};