mirror of
https://github.com/fleetdm/fleet
synced 2026-05-12 03:28:48 +00:00
* #1108 send users to manage queries if error * #1108 fixed tests and lint * #1108 fixed more tests * #1108 new clause to show different error message * #1108 fixed logic
24 lines
766 B
JavaScript
24 lines
766 B
JavaScript
import { push } from "react-router-redux";
|
|
import { join, omit, values } from "lodash";
|
|
|
|
import PATHS from "router/paths";
|
|
import queryActions from "redux/nodes/entities/queries/actions";
|
|
import { renderFlash } from "redux/nodes/notifications/actions";
|
|
|
|
export const fetchQuery = (dispatch, queryID) => {
|
|
return dispatch(queryActions.load(queryID)).catch((errors) => {
|
|
const { MANAGE_QUERIES } = PATHS;
|
|
let errorMessage = join(values(omit(errors, "http_status")), ", ");
|
|
|
|
if (errorMessage.includes("no rows in result set")) {
|
|
errorMessage = "The query you requested does not exist in Fleet.";
|
|
}
|
|
|
|
dispatch(push(MANAGE_QUERIES));
|
|
dispatch(renderFlash("error", errorMessage));
|
|
|
|
return false;
|
|
});
|
|
};
|
|
|
|
export default { fetchQuery };
|