diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-30 06:08:49 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-30 06:08:49 +0000 |
commit | 6305f1dc00870f6e0635e2e850538a00bbd00bda (patch) | |
tree | 8a518cae3805b8d7269bfacc8ae60aa441fadb22 /app/assets/javascripts/notes/mixins | |
parent | 1d388ed855838a2d50588c131f9f23815f148344 (diff) | |
download | gitlab-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.js | 29 |
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); + }, }, }; |