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.js45
1 files changed, 34 insertions, 11 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 d3050183bd3..551dd322c9b 100644
--- a/app/assets/javascripts/ide/stores/modules/merge_requests/actions.js
+++ b/app/assets/javascripts/ide/stores/modules/merge_requests/actions.js
@@ -1,25 +1,48 @@
import { __ } from '../../../../locale';
import Api from '../../../../api';
import flash from '../../../../flash';
+import router from '../../../ide_router';
+import { scopes } from './constants';
import * as types from './mutation_types';
+import * as rootTypes 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 resetMergeRequests = ({ commit }, type) => commit(types.RESET_MERGE_REQUESTS, type);
+
+export const openMergeRequest = ({ commit, dispatch }, { projectPath, id }) => {
+ commit(rootTypes.CLEAR_PROJECTS, null, { root: true });
+ commit(rootTypes.SET_CURRENT_MERGE_REQUEST, `${id}`, { root: true });
+ commit(rootTypes.RESET_OPEN_FILES, null, { root: true });
+ dispatch('setCurrentBranchId', '', { root: true });
+ dispatch('pipelines/stopPipelinePolling', null, { root: true })
+ .then(() => {
+ dispatch('pipelines/resetLatestPipeline', null, { root: true });
+ dispatch('pipelines/clearEtagPoll', null, { root: true });
+ })
+ .catch(e => {
+ throw e;
+ });
+ dispatch('setRightPane', null, { root: true });
+
+ router.push(`/project/${projectPath}/merge_requests/${id}`);
+};
export default () => {};