diff --git a/frontend/redux/nodes/entities/hosts/actions.js b/frontend/redux/nodes/entities/hosts/actions.js deleted file mode 100644 index 4e06bb3353..0000000000 --- a/frontend/redux/nodes/entities/hosts/actions.js +++ /dev/null @@ -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, -}; diff --git a/frontend/redux/nodes/entities/hosts/actions.ts b/frontend/redux/nodes/entities/hosts/actions.ts index de09cb2c99..f7839ea6c0 100644 --- a/frontend/redux/nodes/entities/hosts/actions.ts +++ b/frontend/redux/nodes/entities/hosts/actions.ts @@ -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, };