diff options
Diffstat (limited to 'app/assets/javascripts/search/store/actions.js')
-rw-r--r-- | app/assets/javascripts/search/store/actions.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/assets/javascripts/search/store/actions.js b/app/assets/javascripts/search/store/actions.js new file mode 100644 index 00000000000..447278aa223 --- /dev/null +++ b/app/assets/javascripts/search/store/actions.js @@ -0,0 +1,29 @@ +import Api from '~/api'; +import createFlash from '~/flash'; +import { __ } from '~/locale'; +import { visitUrl, setUrlParams } from '~/lib/utils/url_utility'; +import * as types from './mutation_types'; + +export const fetchGroups = ({ commit }, search) => { + commit(types.REQUEST_GROUPS); + Api.groups(search) + .then(data => { + commit(types.RECEIVE_GROUPS_SUCCESS, data); + }) + .catch(() => { + createFlash({ message: __('There was a problem fetching groups.') }); + commit(types.RECEIVE_GROUPS_ERROR); + }); +}; + +export const setQuery = ({ commit }, { key, value }) => { + commit(types.SET_QUERY, { key, value }); +}; + +export const applyQuery = ({ state }) => { + visitUrl(setUrlParams({ ...state.query, page: null })); +}; + +export const resetQuery = ({ state }) => { + visitUrl(setUrlParams({ ...state.query, page: null, state: null, confidential: null })); +}; |