diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2018-01-18 21:53:13 +0000 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2018-01-18 21:53:13 +0000 |
commit | eb74c22d44ff75a646546f2050105fb04da3cbca (patch) | |
tree | 2c5a529f4185c679055aed8156033706d967bd3a | |
parent | 0eb8c67b14455ca9e96330c21216e251e266b133 (diff) | |
download | gitlab-ce-eb74c22d44ff75a646546f2050105fb04da3cbca.tar.gz |
Refactor dispatcher project mr creations new path
-rw-r--r-- | app/assets/javascripts/dispatcher.js | 17 | ||||
-rw-r--r-- | app/assets/javascripts/pages/projects/merge_requests/creations/new/index.js | 18 |
2 files changed, 21 insertions, 14 deletions
diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 4f8837251bc..158a4a994dd 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -10,7 +10,6 @@ import groupAvatar from './group_avatar'; import GroupLabelSubscription from './group_label_subscription'; import LineHighlighter from './line_highlighter'; import MergeRequest from './merge_request'; -import Compare from './compare'; import Labels from './labels'; import LabelManager from './label_manager'; import Sidebar from './right_sidebar'; @@ -231,19 +230,9 @@ import Activities from './activities'; shortcut_handler = true; break; case 'projects:merge_requests:creations:new': - const mrNewCompareNode = document.querySelector('.js-merge-request-new-compare'); - if (mrNewCompareNode) { - new Compare({ - targetProjectUrl: mrNewCompareNode.dataset.targetProjectUrl, - sourceBranchUrl: mrNewCompareNode.dataset.sourceBranchUrl, - targetBranchUrl: mrNewCompareNode.dataset.targetBranchUrl, - }); - } else { - const mrNewSubmitNode = document.querySelector('.js-merge-request-new-submit'); - new MergeRequest({ - action: mrNewSubmitNode.dataset.mrSubmitAction, - }); - } + import('./pages/projects/merge_requests/creations/new') + .then(callDefault) + .catch(fail); case 'projects:merge_requests:creations:diffs': case 'projects:merge_requests:edit': new Diff(); diff --git a/app/assets/javascripts/pages/projects/merge_requests/creations/new/index.js b/app/assets/javascripts/pages/projects/merge_requests/creations/new/index.js new file mode 100644 index 00000000000..ccd0b54c5ed --- /dev/null +++ b/app/assets/javascripts/pages/projects/merge_requests/creations/new/index.js @@ -0,0 +1,18 @@ +import Compare from '~/compare'; +import MergeRequest from '~/merge_request'; + +export default () => { + const mrNewCompareNode = document.querySelector('.js-merge-request-new-compare'); + if (mrNewCompareNode) { + new Compare({ // eslint-disable-line no-new + targetProjectUrl: mrNewCompareNode.dataset.targetProjectUrl, + sourceBranchUrl: mrNewCompareNode.dataset.sourceBranchUrl, + targetBranchUrl: mrNewCompareNode.dataset.targetBranchUrl, + }); + } else { + const mrNewSubmitNode = document.querySelector('.js-merge-request-new-submit'); + new MergeRequest({ // eslint-disable-line no-new + action: mrNewSubmitNode.dataset.mrSubmitAction, + }); + } +}; |