mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Update /hosts/actions to use one file instead of two (redux) (#1256)
- Bring functions from `actions.js` into `actions.ts` - Remove unused imports from `actions.ts` - Remove `actions.js`
This commit is contained in:
parent
bc4ae0fd1d
commit
5e8566d291
2 changed files with 41 additions and 52 deletions
|
|
@ -1,49 +0,0 @@
|
|||
import Fleet from "fleet";
|
||||
import config from "./config";
|
||||
|
||||
const { actions } = config;
|
||||
|
||||
export const LOAD_PAGINATED = "LOAD_PAGINATED";
|
||||
export const REFETCH_HOST_START = "REFETCH_HOST_START";
|
||||
export const REFETCH_HOST_SUCCESS = "REFETCH_HOST_SUCCESS";
|
||||
export const REFETCH_HOST_FAILURE = "REFETCH_HOST";
|
||||
|
||||
export const loadPaginated = () => {
|
||||
const { loadRequest } = actions;
|
||||
return (dispatch) => {
|
||||
dispatch(loadRequest());
|
||||
|
||||
return Fleet.hosts;
|
||||
};
|
||||
};
|
||||
|
||||
export const refetchHostSuccess = (data) => {
|
||||
return { type: REFETCH_HOST_SUCCESS, payload: { data } };
|
||||
};
|
||||
|
||||
export const refetchHostFailure = (errors) => {
|
||||
return { type: REFETCH_HOST_FAILURE, payload: { errors } };
|
||||
};
|
||||
|
||||
export const refetchHostStart = (host) => {
|
||||
return (dispatch) => {
|
||||
return Fleet.hosts
|
||||
.refetch(host)
|
||||
.then((data) => {
|
||||
dispatch(refetchHostSuccess(data));
|
||||
return data;
|
||||
})
|
||||
.catch((errors) => {
|
||||
dispatch(refetchHostFailure(errors));
|
||||
|
||||
throw errors;
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export default {
|
||||
...actions,
|
||||
refetchHostSuccess,
|
||||
refetchHostFailure,
|
||||
refetchHostStart,
|
||||
};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { ITeam } from "interfaces/team";
|
||||
import { IHost } from "interfaces/host";
|
||||
// @ts-ignore
|
||||
// ignore TS error for now until these are rewritten in ts.
|
||||
import Fleet from "fleet";
|
||||
|
|
@ -6,10 +6,9 @@ import Fleet from "fleet";
|
|||
import { formatErrorResponse } from "redux/nodes/entities/base/helpers";
|
||||
import { IApiError } from "interfaces/errors";
|
||||
import config from "./config";
|
||||
import { addMembersFailure } from "../teams/actions";
|
||||
|
||||
const { actions } = config;
|
||||
const { loadRequest, successAction, updateSuccess } = actions;
|
||||
const { loadRequest } = actions;
|
||||
|
||||
export const TRANSFER_HOSTS_SUCCESS = "TRANSFER_HOSTS_SUCCESS";
|
||||
export const transferHostsSuccess = () => {
|
||||
|
|
@ -42,7 +41,46 @@ const transferToTeam = (teamId: number | null, hostIds: number[]): any => {
|
|||
};
|
||||
};
|
||||
|
||||
export const LOAD_PAGINATED = "LOAD_PAGINATED";
|
||||
export const loadPaginated = (): any => {
|
||||
return (dispatch: any) => {
|
||||
dispatch(loadRequest());
|
||||
|
||||
return Fleet.hosts;
|
||||
};
|
||||
};
|
||||
|
||||
export const REFETCH_HOST_SUCCESS = "REFETCH_HOST_SUCCESS";
|
||||
export const refetchHostSuccess = (data: any) => {
|
||||
return { type: REFETCH_HOST_SUCCESS, payload: { data } };
|
||||
};
|
||||
|
||||
export const REFETCH_HOST_FAILURE = "REFETCH_HOST";
|
||||
export const refetchHostFailure = (errors: any) => {
|
||||
return { type: REFETCH_HOST_FAILURE, payload: { errors } };
|
||||
};
|
||||
|
||||
export const REFETCH_HOST_START = "REFETCH_HOST_START";
|
||||
export const refetchHostStart = (host: IHost): any => {
|
||||
return (dispatch: any) => {
|
||||
return Fleet.hosts
|
||||
.refetch(host)
|
||||
.then((data: any) => {
|
||||
dispatch(refetchHostSuccess(data));
|
||||
return data;
|
||||
})
|
||||
.catch((errors: any) => {
|
||||
dispatch(refetchHostFailure(errors));
|
||||
|
||||
throw errors;
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export default {
|
||||
...actions,
|
||||
transferToTeam,
|
||||
refetchHostSuccess,
|
||||
refetchHostFailure,
|
||||
refetchHostStart,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue