summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/modules/merge_requests/actions.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/ide/stores/modules/merge_requests/actions.js')
-rw-r--r--app/assets/javascripts/ide/stores/modules/merge_requests/actions.js27
1 files changed, 14 insertions, 13 deletions
diff --git a/app/assets/javascripts/ide/stores/modules/merge_requests/actions.js b/app/assets/javascripts/ide/stores/modules/merge_requests/actions.js
index 2b32c0c0b55..83b5b93d3a8 100644
--- a/app/assets/javascripts/ide/stores/modules/merge_requests/actions.js
+++ b/app/assets/javascripts/ide/stores/modules/merge_requests/actions.js
@@ -1,27 +1,28 @@
import { __ } from '../../../../locale';
import Api from '../../../../api';
import flash from '../../../../flash';
+import { scopes } from './constants';
import * as types from './mutation_types';
-export const requestMergeRequests = ({ commit }) => commit(types.REQUEST_MERGE_REQUESTS);
-export const receiveMergeRequestsError = ({ commit }) => {
+export const requestMergeRequests = ({ commit }, type) =>
+ commit(types.REQUEST_MERGE_REQUESTS, type);
+export const receiveMergeRequestsError = ({ commit }, type) => {
flash(__('Error loading merge requests.'));
- commit(types.RECEIVE_MERGE_REQUESTS_ERROR);
+ commit(types.RECEIVE_MERGE_REQUESTS_ERROR, type);
};
-export const receiveMergeRequestsSuccess = ({ commit }, data) =>
- commit(types.RECEIVE_MERGE_REQUESTS_SUCCESS, data);
+export const receiveMergeRequestsSuccess = ({ commit }, { type, data }) =>
+ commit(types.RECEIVE_MERGE_REQUESTS_SUCCESS, { type, data });
-export const fetchMergeRequests = ({ dispatch, state: { scope, state } }, search = '') => {
- dispatch('requestMergeRequests');
- dispatch('resetMergeRequests');
+export const fetchMergeRequests = ({ dispatch, state: { state } }, { type, search = '' }) => {
+ const scope = scopes[type];
+ dispatch('requestMergeRequests', type);
+ dispatch('resetMergeRequests', type);
Api.mergeRequests({ scope, state, search })
- .then(({ data }) => dispatch('receiveMergeRequestsSuccess', data))
- .catch(() => dispatch('receiveMergeRequestsError'));
+ .then(({ data }) => dispatch('receiveMergeRequestsSuccess', { type, data }))
+ .catch(() => dispatch('receiveMergeRequestsError', type));
};
-export const resetMergeRequests = ({ commit }) => commit(types.RESET_MERGE_REQUESTS);
-
-export const setScope = ({ commit }, scope) => commit(types.SET_SCOPE, scope);
+export const resetMergeRequests = ({ commit }, type) => commit(types.RESET_MERGE_REQUESTS, type);
export default () => {};