2017-08-17 22:00:37 +05:30
|
|
|
/* eslint-disable func-names, comma-dangle, new-cap, no-new, max-len */
|
|
|
|
/* global ResolveCount */
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
2017-08-17 22:00:37 +05:30
|
|
|
import Vue from 'vue';
|
2017-09-10 17:25:29 +05:30
|
|
|
import './models/discussion';
|
|
|
|
import './models/note';
|
|
|
|
import './stores/comments';
|
|
|
|
import './services/resolve';
|
|
|
|
import './mixins/discussion';
|
|
|
|
import './components/comment_resolve_btn';
|
|
|
|
import './components/jump_to_discussion';
|
|
|
|
import './components/resolve_btn';
|
|
|
|
import './components/resolve_count';
|
|
|
|
import './components/resolve_discussion_btn';
|
|
|
|
import './components/diff_note_avatars';
|
|
|
|
import './components/new_issue_for_discussion';
|
2018-03-27 19:54:05 +05:30
|
|
|
import { hasVueMRDiscussionsCookie } from '../lib/utils/common_utils';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
export default () => {
|
2018-03-17 18:26:18 +05:30
|
|
|
const projectPathHolder = document.querySelector('.merge-request') || document.querySelector('.commit-box');
|
|
|
|
const projectPath = projectPathHolder.dataset.projectPath;
|
2017-08-17 22:00:37 +05:30
|
|
|
const COMPONENT_SELECTOR = 'resolve-btn, resolve-discussion-btn, jump-to-discussion, comment-and-resolve-btn, new-issue-for-discussion-btn';
|
|
|
|
|
|
|
|
window.gl = window.gl || {};
|
|
|
|
window.gl.diffNoteApps = {};
|
|
|
|
|
|
|
|
window.ResolveService = new gl.DiffNotesResolveServiceClass(projectPath);
|
|
|
|
|
|
|
|
gl.diffNotesCompileComponents = () => {
|
|
|
|
$('diff-note-avatars').each(function () {
|
|
|
|
const tmp = Vue.extend({
|
|
|
|
template: $(this).get(0).outerHTML
|
|
|
|
});
|
|
|
|
const tmpApp = new tmp().$mount();
|
|
|
|
|
|
|
|
$(this).replaceWith(tmpApp.$el);
|
2018-03-17 18:26:18 +05:30
|
|
|
$(tmpApp.$el).one('remove.vue', () => {
|
|
|
|
tmpApp.$destroy();
|
|
|
|
tmpApp.$el.remove();
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
const $components = $(COMPONENT_SELECTOR).filter(function () {
|
|
|
|
return $(this).closest('resolve-count').length !== 1;
|
|
|
|
});
|
|
|
|
|
|
|
|
if ($components) {
|
|
|
|
$components.each(function () {
|
|
|
|
const $this = $(this);
|
|
|
|
const noteId = $this.attr(':note-id');
|
2017-09-10 17:25:29 +05:30
|
|
|
const discussionId = $this.attr(':discussion-id');
|
|
|
|
|
|
|
|
if ($this.is('comment-and-resolve-btn') && !discussionId) return;
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
const tmp = Vue.extend({
|
|
|
|
template: $this.get(0).outerHTML
|
|
|
|
});
|
|
|
|
const tmpApp = new tmp().$mount();
|
|
|
|
|
|
|
|
if (noteId) {
|
|
|
|
gl.diffNoteApps[`note_${noteId}`] = tmpApp;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this.replaceWith(tmpApp.$el);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
gl.diffNotesCompileComponents();
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
if (!hasVueMRDiscussionsCookie()) {
|
|
|
|
new Vue({
|
|
|
|
el: '#resolve-count-app',
|
|
|
|
components: {
|
|
|
|
'resolve-count': ResolveCount
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
$(window).trigger('resize.nav');
|
2018-03-27 19:54:05 +05:30
|
|
|
};
|