debian-mirror-gitlab/app/assets/javascripts/notes/mixins/discussion_navigation.js

30 lines
719 B
JavaScript
Raw Normal View History

2018-11-18 11:00:15 +05:30
import { scrollToElement } from '~/lib/utils/common_utils';
export default {
methods: {
2019-01-03 12:48:30 +05:30
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}"]`;
2018-12-23 12:14:25 +05:30
const el = document.querySelector(selector);
2018-11-18 11:00:15 +05:30
2019-01-03 12:48:30 +05:30
if (activeTab === 'commits' || activeTab === 'pipelines') {
window.mrTabs.activateTab('show');
}
2018-11-18 11:00:15 +05:30
if (el) {
2019-01-03 12:48:30 +05:30
this.expandDiscussion({ discussionId: id });
2018-12-23 12:14:25 +05:30
2019-01-03 12:48:30 +05:30
scrollToElement(el);
2018-11-18 11:00:15 +05:30
return true;
}
}
return false;
},
},
};