import React from 'react'; import { translate as __ } from 'foremanReact/common/I18n'; import { post } from 'foremanReact/redux/API'; import { push } from 'connected-react-router'; import { prepareResult } from './AnsibleRolesAndVariablesHelpers'; import { ANSIBLE_ROLE_CONFIRM_IMPORT_PATH, ANSIBLE_ROLES_INDEX, } from './AnsibleRolesAndVariablesConstants'; export const foremanUrl = path => `${window.URL_PREFIX}${path}`; export const onSubmit = (rows, proxy) => dispatch => { const params = prepareResult(rows); dispatch( post({ key: 'import_ansible_v_r', url: ANSIBLE_ROLE_CONFIRM_IMPORT_PATH, params: { changed: params, proxy }, handleSuccess: () => { setTimeout(() => dispatch(push(ANSIBLE_ROLES_INDEX)), 500); }, successToast: response => ( {__('Import roles and variables started: ')} {__('view the task in progress')} ), errorToast: error => `${__('Failed to import roles and variables ')} ${error}`, }) ); };