2018-07-31 22:21:14 -04:00
|
|
|
import { scrollToElement } from '~/lib/utils/common_utils';
|
2018-12-08 02:19:03 -05:00
|
|
|
import eventHub from '../../notes/event_hub';
|
2018-07-31 22:21:14 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
methods: {
|
2018-12-08 02:19:03 -05:00
|
|
|
diffsJump(id) {
|
|
|
|
const selector = `ul.notes[data-discussion-id="${id}"]`;
|
2018-07-31 22:21:14 -04:00
|
|
|
|
2018-12-08 02:19:03 -05:00
|
|
|
eventHub.$once('scrollToDiscussion', () => {
|
|
|
|
const el = document.querySelector(selector);
|
2018-07-31 22:21:14 -04:00
|
|
|
|
|
|
|
if (el) {
|
|
|
|
scrollToElement(el);
|
2018-12-08 02:19:03 -05:00
|
|
|
|
2018-07-31 22:21:14 -04:00
|
|
|
return true;
|
|
|
|
}
|
2018-12-08 02:19:03 -05:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.expandDiscussion({ discussionId: id });
|
|
|
|
},
|
|
|
|
discussionJump(id) {
|
|
|
|
const selector = `div.discussion[data-discussion-id="${id}"]`;
|
|
|
|
|
|
|
|
const el = document.querySelector(selector);
|
|
|
|
|
|
|
|
this.expandDiscussion({ discussionId: id });
|
|
|
|
|
|
|
|
if (el) {
|
|
|
|
scrollToElement(el);
|
|
|
|
|
|
|
|
return true;
|
2018-07-31 22:21:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
2018-12-08 02:19:03 -05:00
|
|
|
jumpToDiscussion(id) {
|
|
|
|
if (id) {
|
|
|
|
const activeTab = window.mrTabs.currentAction;
|
|
|
|
|
|
|
|
if (activeTab === 'diffs') {
|
|
|
|
this.diffsJump(id);
|
|
|
|
} else if (activeTab === 'commits' || activeTab === 'pipelines') {
|
|
|
|
window.mrTabs.eventHub.$once('MergeRequestTabChange', () => {
|
|
|
|
setTimeout(() => this.discussionJump(id), 0);
|
|
|
|
});
|
|
|
|
|
|
|
|
window.mrTabs.tabShown('show');
|
|
|
|
} else {
|
|
|
|
this.discussionJump(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-07-31 22:21:14 -04:00
|
|
|
},
|
|
|
|
};
|