webpack/scenes/AlternateContentSources/ACSActions.js in katello-4.5.1 vs webpack/scenes/AlternateContentSources/ACSActions.js in katello-4.6.0.rc1
- old
+ new
@@ -1,9 +1,16 @@
import { API_OPERATIONS, APIActions, get, post } from 'foremanReact/redux/API';
import { translate as __ } from 'foremanReact/common/I18n';
import api, { orgId } from '../../services/api';
-import ACS_KEY, { acsRefreshKey, CREATE_ACS_KEY, DELETE_ACS_KEY } from './ACSConstants';
+import ACS_KEY, {
+ acsDetailsKey,
+ acsRefreshKey,
+ CREATE_ACS_KEY,
+ DELETE_ACS_KEY,
+ EDIT_ACS_KEY,
+ PRODUCTS_KEY,
+} from './ACSConstants';
import { getResponseErrorMsgs } from '../../utils/helpers';
import { renderTaskStartedToast } from '../Tasks/helpers';
const acsSuccessToast = (response) => {
const { data: { name } } = response;
@@ -28,10 +35,17 @@
key: ACS_KEY + id,
url: api.getApiUrl('/alternate_content_sources'),
params: createACSParams(extraParams),
});
+export const getACSDetails = (acsId, extraParams = {}) => get({
+ type: API_OPERATIONS.GET,
+ key: acsDetailsKey(acsId),
+ params: { organization_id: orgId(), include_permissions: true, ...extraParams },
+ url: api.getApiUrl(`/alternate_content_sources/${acsId}`),
+});
+
export const createACS = params => post({
type: API_OPERATIONS.POST,
key: CREATE_ACS_KEY,
url: api.getApiUrl('/alternate_content_sources'),
params,
@@ -57,9 +71,28 @@
if (handleSuccess) handleSuccess();
return renderTaskStartedToast(response.data);
},
errorToast: error => __(`Something went wrong while refreshing this alternate content source! ${getResponseErrorMsgs(error.response)}`),
});
+
+export const getProducts = () => get({
+ type: API_OPERATIONS.GET,
+ key: PRODUCTS_KEY,
+ url: api.getApiUrl('/products'),
+ params: {
+ organization_id: orgId(), full_result: true, enabled: true, non_empty: true,
+ },
+});
+
+export const editACS = (acsId, params, handleSuccess, handleError) => APIActions.put({
+ type: API_OPERATIONS.PUT,
+ key: EDIT_ACS_KEY,
+ url: api.getApiUrl(`/alternate_content_sources/${acsId}`),
+ params,
+ handleSuccess,
+ handleError,
+ successToast: () => __('Alternate content source edited'),
+ errorToast: error => __(`Something went wrong while editing the alternate content source! ${getResponseErrorMsgs(error.response)}`),
+});
+
export default getAlternateContentSources;
-// acs = Katello::AlternateContentSource.new
-// (name:"acs", label:"acs", alternate_content_source_type:"custom", base_url:"abcdef")