diff options
Diffstat (limited to 'app/assets/javascripts/projects/commit/store/actions.js')
-rw-r--r-- | app/assets/javascripts/projects/commit/store/actions.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/app/assets/javascripts/projects/commit/store/actions.js b/app/assets/javascripts/projects/commit/store/actions.js new file mode 100644 index 00000000000..2ae0370d579 --- /dev/null +++ b/app/assets/javascripts/projects/commit/store/actions.js @@ -0,0 +1,36 @@ +import * as types from './mutation_types'; +import axios from '~/lib/utils/axios_utils'; +import createFlash from '~/flash'; +import { PROJECT_BRANCHES_ERROR } from '../constants'; + +export const clearModal = ({ commit }) => { + commit(types.CLEAR_MODAL); +}; + +export const requestBranches = ({ commit }) => { + commit(types.REQUEST_BRANCHES); +}; + +export const fetchBranches = ({ commit, dispatch, state }, query) => { + dispatch('requestBranches'); + + return axios + .get(state.branchesEndpoint, { + params: { search: query }, + }) + .then((res) => { + commit(types.RECEIVE_BRANCHES_SUCCESS, res.data); + }) + .catch(() => { + createFlash({ message: PROJECT_BRANCHES_ERROR }); + }); +}; + +export const setBranch = ({ commit, dispatch }, branch) => { + commit(types.SET_BRANCH, branch); + dispatch('setSelectedBranch', branch); +}; + +export const setSelectedBranch = ({ commit }, branch) => { + commit(types.SET_SELECTED_BRANCH, branch); +}; |