diff options
author | André Luís <me@andr3.net> | 2018-07-20 15:24:46 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-07-20 15:24:46 +0000 |
commit | f2f8ddf4ccc43c86d8432a63b11aba8b216afd41 (patch) | |
tree | 649bc3f17a91f969b3d5b8439825e3b6a32e2bec /app/assets/javascripts/notes/mixins | |
parent | 9b01b293ce5ddbaeedaf014cdc804af2c5e86416 (diff) | |
download | gitlab-ce-f2f8ddf4ccc43c86d8432a63b11aba8b216afd41.tar.gz |
Resolve ""Jump to first/next unresolved discussion" jumps to resolved discussions"
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 new file mode 100644 index 00000000000..f7c4deee1f8 --- /dev/null +++ b/app/assets/javascripts/notes/mixins/discussion_navigation.js @@ -0,0 +1,29 @@ +import { scrollToElement } from '~/lib/utils/common_utils'; + +export default { + methods: { + jumpToDiscussion(id) { + if (id) { + const activeTab = window.mrTabs.currentAction; + const selector = + activeTab === 'diffs' + ? `ul.notes[data-discussion-id="${id}"]` + : `div.discussion[data-discussion-id="${id}"]`; + const el = document.querySelector(selector); + + if (activeTab === 'commits' || activeTab === 'pipelines') { + window.mrTabs.activateTab('show'); + } + + if (el) { + this.expandDiscussion({ discussionId: id }); + + scrollToElement(el); + return true; + } + } + + return false; + }, + }, +}; |