webpack/scenes/AlternateContentSources/ACSActions.js in katello-4.5.0.rc1 vs webpack/scenes/AlternateContentSources/ACSActions.js in katello-4.5.0.rc2

- old
+ new

@@ -1,10 +1,11 @@ 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, { CREATE_ACS_KEY, DELETE_ACS_KEY } from './ACSConstants'; +import ACS_KEY, { acsRefreshKey, CREATE_ACS_KEY, DELETE_ACS_KEY } from './ACSConstants'; import { getResponseErrorMsgs } from '../../utils/helpers'; +import { renderTaskStartedToast } from '../Tasks/helpers'; const acsSuccessToast = (response) => { const { data: { name } } = response; return __(`Alternate content source ${name} created`); }; @@ -45,9 +46,20 @@ handleSuccess, successToast: () => __('Alternate content source deleted'), errorToast: error => __(`Something went wrong while deleting this alternate content source! ${getResponseErrorMsgs(error.response)}`), }); +export const refreshACS = (acsId, handleSuccess) => post({ + type: API_OPERATIONS.POST, + key: acsRefreshKey(acsId), + url: api.getApiUrl(`/alternate_content_sources/${acsId}/refresh`), + params: { id: acsId }, + handleSuccess: (response) => { + if (handleSuccess) handleSuccess(); + return renderTaskStartedToast(response.data); + }, + errorToast: error => __(`Something went wrong while refreshing this 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")