fleet/frontend/components/queries/QueryPageWrapper/helpers.js
Mike Stone 01e7ac2b6c Create query (#382)
* API call to create queries

* Add queries to redux

* create query when query form is submitted

* Redirect to ShowQueryPage after creating query

* Removes theme dropdown and NewQuery component header

* Extract NewQueryPage component state to redux state

* Pass logic down to NewQuery component as props

* Changes NewQuery component name to QueryComposer

* Render NewQueryPage for /queries/:id route

* Update ReduxConfig for loading a single resource

* QueryPage tests

* Get query when the query page loads

* catch errors when query is invalid

* Renames UpdateQueryForm to QueryForm to re-usability

* Changes InputField to a controlled component

* Always render the Query Form on Query Pages
2016-11-07 11:42:39 -05:00

18 lines
491 B
JavaScript

import { push } from 'react-router-redux';
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((errorResponse) => {
const { error } = errorResponse;
dispatch(push('/queries/new'));
dispatch(renderFlash('error', error));
return false;
});
};
export default { fetchQuery };