blob: 10135e55351332289a74b124707f87478f9369aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { PROJECT_BRANCHES_ERROR } from '../constants';
import * as types from './mutation_types';
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);
};
|