Commit 18da66a5 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'remove-iife-diff-notes-bundle' into 'master'

Remove IIFE's in diff_notes_bundle.js

See merge request !10729
parents ba1e9495 e8561287
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
import Vue from 'vue'; import Vue from 'vue';
(() => { const CommentAndResolveBtn = Vue.extend({
const CommentAndResolveBtn = Vue.extend({
props: { props: {
discussionId: String, discussionId: String,
}, },
...@@ -61,7 +60,6 @@ import Vue from 'vue'; ...@@ -61,7 +60,6 @@ import Vue from 'vue';
$(`.js-discussion-note-form[data-discussion-id=${this.discussionId}] .note-textarea`).off('input.comment-and-resolve-btn'); $(`.js-discussion-note-form[data-discussion-id=${this.discussionId}] .note-textarea`).off('input.comment-and-resolve-btn');
} }
}); });
Vue.component('comment-and-resolve-btn', CommentAndResolveBtn); Vue.component('comment-and-resolve-btn', CommentAndResolveBtn);
})(window);
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
import Vue from 'vue'; import Vue from 'vue';
import collapseIcon from '../icons/collapse_icon.svg'; import collapseIcon from '../icons/collapse_icon.svg';
(() => { const DiffNoteAvatars = Vue.extend({
const DiffNoteAvatars = Vue.extend({
props: ['discussionId'], props: ['discussionId'],
data() { data() {
return { return {
...@@ -152,7 +151,6 @@ import collapseIcon from '../icons/collapse_icon.svg'; ...@@ -152,7 +151,6 @@ import collapseIcon from '../icons/collapse_icon.svg';
this.isVisible = $(`.diffs .notes[data-discussion-id="${this.discussion.id}"]`).is(':visible'); this.isVisible = $(`.diffs .notes[data-discussion-id="${this.discussion.id}"]`).is(':visible');
}, },
}, },
}); });
Vue.component('diff-note-avatars', DiffNoteAvatars); Vue.component('diff-note-avatars', DiffNoteAvatars);
})();
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
import Vue from 'vue'; import Vue from 'vue';
(() => { const JumpToDiscussion = Vue.extend({
const JumpToDiscussion = Vue.extend({
mixins: [DiscussionMixins], mixins: [DiscussionMixins],
props: { props: {
discussionId: String discussionId: String
...@@ -189,7 +188,6 @@ import Vue from 'vue'; ...@@ -189,7 +188,6 @@ import Vue from 'vue';
created() { created() {
this.discussion = this.discussions[this.discussionId]; this.discussion = this.discussions[this.discussionId];
}, },
}); });
Vue.component('jump-to-discussion', JumpToDiscussion); Vue.component('jump-to-discussion', JumpToDiscussion);
})();
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
import Vue from 'vue'; import Vue from 'vue';
(() => { const NewIssueForDiscussion = Vue.extend({
const NewIssueForDiscussion = Vue.extend({
props: { props: {
discussionId: { discussionId: {
type: String, type: String,
...@@ -24,7 +23,6 @@ import Vue from 'vue'; ...@@ -24,7 +23,6 @@ import Vue from 'vue';
return false; return false;
}, },
}, },
}); });
Vue.component('new-issue-for-discussion-btn', NewIssueForDiscussion); Vue.component('new-issue-for-discussion-btn', NewIssueForDiscussion);
})();
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
import Vue from 'vue'; import Vue from 'vue';
(() => { const ResolveBtn = Vue.extend({
const ResolveBtn = Vue.extend({
props: { props: {
noteId: Number, noteId: Number,
discussionId: String, discussionId: String,
...@@ -115,7 +114,6 @@ import Vue from 'vue'; ...@@ -115,7 +114,6 @@ import Vue from 'vue';
noteTruncated: this.noteTruncated, noteTruncated: this.noteTruncated,
}); });
} }
}); });
Vue.component('resolve-btn', ResolveBtn); Vue.component('resolve-btn', ResolveBtn);
})();
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
import Vue from 'vue'; import Vue from 'vue';
((w) => { window.ResolveCount = Vue.extend({
w.ResolveCount = Vue.extend({
mixins: [DiscussionMixins], mixins: [DiscussionMixins],
props: { props: {
loggedOut: Boolean loggedOut: Boolean
...@@ -23,5 +22,4 @@ import Vue from 'vue'; ...@@ -23,5 +22,4 @@ import Vue from 'vue';
return this.discussionCount === 1 ? 'discussion' : 'discussions'; return this.discussionCount === 1 ? 'discussion' : 'discussions';
} }
} }
}); });
})(window);
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
import Vue from 'vue'; import Vue from 'vue';
(() => { const ResolveDiscussionBtn = Vue.extend({
const ResolveDiscussionBtn = Vue.extend({
props: { props: {
discussionId: String, discussionId: String,
mergeRequestId: Number, mergeRequestId: Number,
...@@ -56,7 +55,6 @@ import Vue from 'vue'; ...@@ -56,7 +55,6 @@ import Vue from 'vue';
this.discussion = CommentsStore.state[this.discussionId]; this.discussion = CommentsStore.state[this.discussionId];
} }
}); });
Vue.component('resolve-discussion-btn', ResolveDiscussionBtn); Vue.component('resolve-discussion-btn', ResolveDiscussionBtn);
})();
/* eslint-disable object-shorthand, func-names, guard-for-in, no-restricted-syntax, comma-dangle, no-param-reassign, max-len */ /* eslint-disable object-shorthand, func-names, guard-for-in, no-restricted-syntax, comma-dangle, no-param-reassign, max-len */
((w) => { window.DiscussionMixins = {
w.DiscussionMixins = {
computed: { computed: {
discussionCount: function () { discussionCount: function () {
return Object.keys(this.discussions).length; return Object.keys(this.discussions).length;
...@@ -33,5 +32,4 @@ ...@@ -33,5 +32,4 @@
return unresolvedCount; return unresolvedCount;
} }
} }
}; };
})(window);
...@@ -9,10 +9,9 @@ require('../../vue_shared/vue_resource_interceptor'); ...@@ -9,10 +9,9 @@ require('../../vue_shared/vue_resource_interceptor');
Vue.use(VueResource); Vue.use(VueResource);
(() => { window.gl = window.gl || {};
window.gl = window.gl || {};
class ResolveServiceClass { class ResolveServiceClass {
constructor(root) { constructor(root) {
this.noteResource = Vue.resource(`${root}/notes{/noteId}/resolve`); this.noteResource = Vue.resource(`${root}/notes{/noteId}/resolve`);
this.discussionResource = Vue.resource(`${root}/merge_requests{/mergeRequestId}/discussions{/discussionId}/resolve`); this.discussionResource = Vue.resource(`${root}/merge_requests{/mergeRequestId}/discussions{/discussionId}/resolve`);
...@@ -78,7 +77,6 @@ Vue.use(VueResource); ...@@ -78,7 +77,6 @@ Vue.use(VueResource);
discussionId discussionId
}, {}); }, {});
} }
} }
gl.DiffNotesResolveServiceClass = ResolveServiceClass; gl.DiffNotesResolveServiceClass = ResolveServiceClass;
})();
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
import Vue from 'vue'; import Vue from 'vue';
((w) => { window.CommentsStore = {
w.CommentsStore = {
state: {}, state: {},
get: function (discussionId, noteId) { get: function (discussionId, noteId) {
return this.state[discussionId].getNote(noteId); return this.state[discussionId].getNote(noteId);
...@@ -54,5 +53,4 @@ import Vue from 'vue'; ...@@ -54,5 +53,4 @@ import Vue from 'vue';
return ids; return ids;
} }
}; };
})(window);
...@@ -5,8 +5,7 @@ require('~/diff_notes/models/discussion'); ...@@ -5,8 +5,7 @@ require('~/diff_notes/models/discussion');
require('~/diff_notes/models/note'); require('~/diff_notes/models/note');
require('~/diff_notes/stores/comments'); require('~/diff_notes/stores/comments');
(() => { function createDiscussion(noteId = 1, resolved = true) {
function createDiscussion(noteId = 1, resolved = true) {
CommentsStore.create({ CommentsStore.create({
discussionId: 'a', discussionId: 'a',
noteId, noteId,
...@@ -17,13 +16,13 @@ require('~/diff_notes/stores/comments'); ...@@ -17,13 +16,13 @@ require('~/diff_notes/stores/comments');
authorAvatar: 'test', authorAvatar: 'test',
noteTruncated: 'test...', noteTruncated: 'test...',
}); });
} }
beforeEach(() => { beforeEach(() => {
CommentsStore.state = {}; CommentsStore.state = {};
}); });
describe('New discussion', () => { describe('New discussion', () => {
it('creates new discussion', () => { it('creates new discussion', () => {
expect(Object.keys(CommentsStore.state).length).toBe(0); expect(Object.keys(CommentsStore.state).length).toBe(0);
createDiscussion(); createDiscussion();
...@@ -37,9 +36,9 @@ require('~/diff_notes/stores/comments'); ...@@ -37,9 +36,9 @@ require('~/diff_notes/stores/comments');
const discussion = CommentsStore.state['a']; const discussion = CommentsStore.state['a'];
expect(Object.keys(discussion.notes).length).toBe(2); expect(Object.keys(discussion.notes).length).toBe(2);
}); });
}); });
describe('Get note', () => { describe('Get note', () => {
beforeEach(() => { beforeEach(() => {
expect(Object.keys(CommentsStore.state).length).toBe(0); expect(Object.keys(CommentsStore.state).length).toBe(0);
createDiscussion(); createDiscussion();
...@@ -50,9 +49,9 @@ require('~/diff_notes/stores/comments'); ...@@ -50,9 +49,9 @@ require('~/diff_notes/stores/comments');
expect(note).toBeDefined(); expect(note).toBeDefined();
expect(note.id).toBe(1); expect(note.id).toBe(1);
}); });
}); });
describe('Delete discussion', () => { describe('Delete discussion', () => {
beforeEach(() => { beforeEach(() => {
expect(Object.keys(CommentsStore.state).length).toBe(0); expect(Object.keys(CommentsStore.state).length).toBe(0);
createDiscussion(); createDiscussion();
...@@ -73,9 +72,9 @@ require('~/diff_notes/stores/comments'); ...@@ -73,9 +72,9 @@ require('~/diff_notes/stores/comments');
CommentsStore.delete('a', 2); CommentsStore.delete('a', 2);
expect(Object.keys(CommentsStore.state).length).toBe(0); expect(Object.keys(CommentsStore.state).length).toBe(0);
}); });
}); });
describe('Update note', () => { describe('Update note', () => {
beforeEach(() => { beforeEach(() => {
expect(Object.keys(CommentsStore.state).length).toBe(0); expect(Object.keys(CommentsStore.state).length).toBe(0);
createDiscussion(); createDiscussion();
...@@ -87,9 +86,9 @@ require('~/diff_notes/stores/comments'); ...@@ -87,9 +86,9 @@ require('~/diff_notes/stores/comments');
const note = CommentsStore.get('a', 1); const note = CommentsStore.get('a', 1);
expect(note.resolved).toBe(false); expect(note.resolved).toBe(false);
}); });
}); });
describe('Discussion resolved', () => { describe('Discussion resolved', () => {
beforeEach(() => { beforeEach(() => {
expect(Object.keys(CommentsStore.state).length).toBe(0); expect(Object.keys(CommentsStore.state).length).toBe(0);
createDiscussion(); createDiscussion();
...@@ -129,5 +128,4 @@ require('~/diff_notes/stores/comments'); ...@@ -129,5 +128,4 @@ require('~/diff_notes/stores/comments');
discussion.unResolveAllNotes(); discussion.unResolveAllNotes();
expect(discussion.isResolved()).toBe(false); expect(discussion.isResolved()).toBe(false);
}); });
}); });
})();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment