fleet/frontend/pages/hosts/HostDetailsPage/helpers.js
RachelElysia 2036b4ded6
Host details page: Refetch button (frontend) (#765)
Feature: Refetch button on the host details page
* Button refetches data for an online host
* Button disabled with UI tooltip for an offline host
2021-05-17 19:10:59 -04:00

48 lines
1.0 KiB
JavaScript

import { push } from "react-router-redux";
import PATHS from "router/paths";
import hostActions from "redux/nodes/entities/hosts/actions";
export const fetchHost = (dispatch, hostID) => {
return dispatch(hostActions.load(hostID)).catch(() => {
dispatch(push(PATHS.FLEET_500));
return false;
});
};
export const destroyHost = (dispatch, host) => {
return dispatch(hostActions.destroy(host)).then(() => {
dispatch(push(PATHS.HOME));
});
};
export const refetchHost = (dispatch, host) => {
return dispatch(hostActions.refetchHostStart(host));
};
export const queryHostCustom = (dispatch, host) => {
return dispatch(
push({
pathname: PATHS.NEW_QUERY,
query: { host_ids: [host.id] },
})
);
};
export const queryHostSaved = (dispatch, host, selectedQuery) => {
return dispatch(
push({
pathname: PATHS.EDIT_QUERY(selectedQuery),
query: { host_ids: [host.id] },
})
);
};
export default {
fetchHost,
destroyHost,
queryHostCustom,
queryHostSaved,
refetchHost,
};