mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 09:18:59 +00:00
2036b4ded6
Feature: Refetch button on the host details page * Button refetches data for an online host * Button disabled with UI tooltip for an offline host
48 lines
1.0 KiB
JavaScript
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,
|
|
};
|