Sha256: 509d2fd6264fac1620da9ae2f9c1d0d4436ffffa2a645d3244035d17e9a65160
Contents?: true
Size: 1015 Bytes
Versions: 27
Compression:
Stored size: 1015 Bytes
Contents
import { foremanUrl } from 'foremanReact/common/helpers'; import { sprintf, translate as __ } from 'foremanReact/common/I18n'; import { post } from 'foremanReact/redux/API'; export const runFeature = (hostId, feature, label) => dispatch => { const url = foremanUrl( `/job_invocations?feature=${feature}&host_ids%5B%5D=${hostId}` ); const redirectUrl = 'job_invocations/new'; const successToast = ({ request }) => { if (request.responseURL.includes(redirectUrl)) { return __('Opening job invocation form'); } return sprintf(__('%s job has been invoked'), label); }; const errorToast = ({ message }) => message; dispatch( post({ key: feature.toUpperCase(), url, successToast, errorToast, handleSuccess: ({ request }) => { if (request.responseURL.includes(redirectUrl)) { // checking if user should be redicted to finish setting up the job window.location.href = request.responseURL; } }, }) ); };
Version data entries
27 entries across 27 versions & 1 rubygems