Sha256: 218564fc485851040dc87054323cc8a8f0ad79c87e6b7180b81a4f5275837cbd
Contents?: true
Size: 1.23 KB
Versions: 19
Compression:
Stored size: 1.23 KB
Contents
import React from 'react'; import API from 'foremanReact/API'; import { addToast } from 'foremanReact/redux/actions/toasts'; import { inventoryUrl } from '../../../../ForemanInventoryHelpers'; import Toast from './components/Toast'; import { INVENTORY_SYNC_REQUEST, INVENTORY_SYNC_SUCCESS, INVENTORY_SYNC_ERROR, } from './SyncButtonConstants'; export const handleSync = () => async dispatch => { dispatch({ type: INVENTORY_SYNC_REQUEST, payload: {}, }); try { const { data: { syncHosts, disconnectHosts }, } = await API.post(inventoryUrl('tasks')); dispatch({ type: INVENTORY_SYNC_SUCCESS, payload: { syncHosts, disconnectHosts, }, }); dispatch( addToast({ sticky: true, type: 'success', message: ( <Toast syncHosts={syncHosts} disconnectHosts={disconnectHosts} /> ), }) ); } catch ({ message, response: { data: { message: toastMessage } = {} } = {}, }) { dispatch({ type: INVENTORY_SYNC_ERROR, payload: { error: message, }, }); dispatch( addToast({ sticky: true, type: 'error', message: toastMessage || message, }) ); } };
Version data entries
19 entries across 19 versions & 1 rubygems