summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/notes/mixins
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-30 06:08:49 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-30 06:08:49 +0000
commit6305f1dc00870f6e0635e2e850538a00bbd00bda (patch)
tree8a518cae3805b8d7269bfacc8ae60aa441fadb22 /app/assets/javascripts/notes/mixins
parent1d388ed855838a2d50588c131f9f23815f148344 (diff)
downloadgitlab-ce-6305f1dc00870f6e0635e2e850538a00bbd00bda.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/notes/mixins')
-rw-r--r--app/assets/javascripts/notes/mixins/discussion_navigation.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/assets/javascripts/notes/mixins/discussion_navigation.js b/app/assets/javascripts/notes/mixins/discussion_navigation.js
index 94ca01e44cc..e5066695403 100644
--- a/app/assets/javascripts/notes/mixins/discussion_navigation.js
+++ b/app/assets/javascripts/notes/mixins/discussion_navigation.js
@@ -1,8 +1,21 @@
+import { mapGetters, mapActions, mapState } from 'vuex';
import { scrollToElement } from '~/lib/utils/common_utils';
import eventHub from '../../notes/event_hub';
export default {
+ computed: {
+ ...mapGetters([
+ 'nextUnresolvedDiscussionId',
+ 'previousUnresolvedDiscussionId',
+ 'getDiscussion',
+ ]),
+ ...mapState({
+ currentDiscussionId: state => state.notes.currentDiscussionId,
+ }),
+ },
methods: {
+ ...mapActions(['expandDiscussion', 'setCurrentDiscussionId']),
+
diffsJump(id) {
const selector = `ul.notes[data-discussion-id="${id}"]`;
@@ -58,5 +71,21 @@ export default {
}
}
},
+
+ jumpToNextDiscussion() {
+ this.handleDiscussionJump(this.nextUnresolvedDiscussionId);
+ },
+
+ jumpToPreviousDiscussion() {
+ this.handleDiscussionJump(this.previousUnresolvedDiscussionId);
+ },
+
+ handleDiscussionJump(fn) {
+ const isDiffView = window.mrTabs.currentAction === 'diffs';
+ const targetId = fn(this.currentDiscussionId, isDiffView);
+ const discussion = this.getDiscussion(targetId);
+ this.jumpToDiscussion(discussion);
+ this.setCurrentDiscussionId(targetId);
+ },
},
};