diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2018-03-23 11:45:43 +0100 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2018-03-28 12:17:02 +0200 |
commit | f62359c23b86bb8c8dc241ff4e09bab24e74ccbd (patch) | |
tree | f2ac4a95d433ce476fd5337cabed81c8bb524530 /app/assets/javascripts/ide/ide_router.js | |
parent | 06afa5a3ff82e2d6edbcf668cc870e625784c09c (diff) | |
download | gitlab-ce-f62359c23b86bb8c8dc241ff4e09bab24e74ccbd.tar.gz |
Basic Setup for MR Showing
Diffstat (limited to 'app/assets/javascripts/ide/ide_router.js')
-rw-r--r-- | app/assets/javascripts/ide/ide_router.js | 81 |
1 files changed, 80 insertions, 1 deletions
diff --git a/app/assets/javascripts/ide/ide_router.js b/app/assets/javascripts/ide/ide_router.js index db89c1d44db..f054a0a0364 100644 --- a/app/assets/javascripts/ide/ide_router.js +++ b/app/assets/javascripts/ide/ide_router.js @@ -2,6 +2,7 @@ import Vue from 'vue'; import VueRouter from 'vue-router'; import flash from '~/flash'; import store from './stores'; +import { getTreeEntry } from './stores/utils'; Vue.use(VueRouter); @@ -44,7 +45,7 @@ const router = new VueRouter({ component: EmptyRouterComponent, }, { - path: 'mr/:mrid', + path: 'merge_requests/:mrid', component: EmptyRouterComponent, }, ], @@ -96,6 +97,84 @@ router.beforeEach((to, from, next) => { ); throw e; }); + } else if (to.params.mrid) { + store.dispatch('updateViewer', 'mrdiff'); + + store + .dispatch('getMergeRequestData', { + projectId: fullProjectId, + mergeRequestId: to.params.mrid, + }) + .then(mr => { + store.dispatch('getBranchData', { + projectId: fullProjectId, + branchId: mr.source_branch, + }); + + store + .dispatch('getFiles', { + projectId: fullProjectId, + branchId: mr.source_branch, + }) + .then(() => { + store + .dispatch('getMergeRequestChanges', { + projectId: fullProjectId, + mergeRequestId: to.params.mrid, + }) + .then(mrChanges => { + if (mrChanges.changes.length > 0) { + } + mrChanges.changes.forEach((change, ind) => { + console.log(`CHANGE : ${ind} : `, change); + + const changeTreeEntry = + store.state.entries[change.new_path]; + + console.log( + 'Tree Entry for the change ', + changeTreeEntry, + change.diff, + ); + + if (changeTreeEntry) { + store.dispatch('setFileMrDiff', { + file: changeTreeEntry, + mrDiff: change.diff, + }); + store.dispatch('setFileTargetBranch', { + file: changeTreeEntry, + targetBranch: mrChanges.target_branch, + }); + + if (ind === 0) { + store.dispatch('getFileData', change.new_path); + } else { + // TODO : Implement Tab reloading + store.dispatch('preloadFileTab', changeTreeEntry); + } + } else { + console.warn(`No Tree Entry for ${change.new_path}`); + } + }); + }) + .catch(e => { + flash( + 'Error while loading the merge request changes. Please try again.', + ); + throw e; + }); + }) + .catch(e => { + flash( + 'Error while loading the branch files. Please try again.', + ); + throw e; + }); + }) + .catch(e => { + throw e; + }); } }) .catch(e => { |