Sha256: b0b0c7f7c3268544d4834b8e4be7085829c798723ab9a2e73e4515335467dc01
Contents?: true
Size: 1.08 KB
Versions: 24
Compression:
Stored size: 1.08 KB
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, hostSearch) => dispatch => { const url = foremanUrl( hostId ? `/job_invocations?feature=${feature}&host_ids%5B%5D=${hostId}` : `/job_invocations?feature=${feature}&search=${hostSearch}` ); 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
24 entries across 24 versions & 1 rubygems