Commit 52abaa1e authored by Alfredo Sumaran's avatar Alfredo Sumaran Committed by Alfredo Sumaran

Remove IIFEs from diff_notes_bundle.js

# Conflicts:
#	app/assets/javascripts/diff_notes/components/resolve_btn.js
parent 4d1b2d41
......@@ -3,8 +3,7 @@
import Vue from 'vue';
(() => {
const CommentAndResolveBtn = Vue.extend({
const CommentAndResolveBtn = Vue.extend({
props: {
discussionId: String,
},
......@@ -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');
}
});
});
Vue.component('comment-and-resolve-btn', CommentAndResolveBtn);
})(window);
Vue.component('comment-and-resolve-btn', CommentAndResolveBtn);
......@@ -4,8 +4,7 @@
import Vue from 'vue';
import collapseIcon from '../icons/collapse_icon.svg';
(() => {
const DiffNoteAvatars = Vue.extend({
const DiffNoteAvatars = Vue.extend({
props: ['discussionId'],
data() {
return {
......@@ -152,7 +151,6 @@ import collapseIcon from '../icons/collapse_icon.svg';
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 @@
import Vue from 'vue';
(() => {
const JumpToDiscussion = Vue.extend({
const JumpToDiscussion = Vue.extend({
mixins: [DiscussionMixins],
props: {
discussionId: String
......@@ -189,7 +188,6 @@ import Vue from 'vue';
created() {
this.discussion = this.discussions[this.discussionId];
},
});
});
Vue.component('jump-to-discussion', JumpToDiscussion);
})();
Vue.component('jump-to-discussion', JumpToDiscussion);
......@@ -2,8 +2,7 @@
import Vue from 'vue';
(() => {
const NewIssueForDiscussion = Vue.extend({
const NewIssueForDiscussion = Vue.extend({
props: {
discussionId: {
type: String,
......@@ -24,7 +23,6 @@ import Vue from 'vue';
return false;
},
},
});
});
Vue.component('new-issue-for-discussion-btn', NewIssueForDiscussion);
})();
Vue.component('new-issue-for-discussion-btn', NewIssueForDiscussion);
......@@ -5,8 +5,7 @@
import Vue from 'vue';
(() => {
const ResolveBtn = Vue.extend({
const ResolveBtn = Vue.extend({
props: {
noteId: Number,
discussionId: String,
......@@ -115,7 +114,6 @@ import Vue from 'vue';
this.note = this.discussion.getNote(this.noteId);
}
});
});
Vue.component('resolve-btn', ResolveBtn);
})();
Vue.component('resolve-btn', ResolveBtn);
......@@ -4,8 +4,7 @@
import Vue from 'vue';
((w) => {
w.ResolveCount = Vue.extend({
window.ResolveCount = Vue.extend({
mixins: [DiscussionMixins],
props: {
loggedOut: Boolean
......@@ -23,5 +22,4 @@ import Vue from 'vue';
return this.discussionCount === 1 ? 'discussion' : 'discussions';
}
}
});
})(window);
});
......@@ -4,8 +4,7 @@
import Vue from 'vue';
(() => {
const ResolveDiscussionBtn = Vue.extend({
const ResolveDiscussionBtn = Vue.extend({
props: {
discussionId: String,
mergeRequestId: Number,
......@@ -56,7 +55,6 @@ import Vue from 'vue';
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 */
((w) => {
w.DiscussionMixins = {
window.DiscussionMixins = {
computed: {
discussionCount: function () {
return Object.keys(this.discussions).length;
......@@ -33,5 +32,4 @@
return unresolvedCount;
}
}
};
})(window);
};
......@@ -9,10 +9,9 @@ require('../../vue_shared/vue_resource_interceptor');
Vue.use(VueResource);
(() => {
window.gl = window.gl || {};
window.gl = window.gl || {};
class ResolveServiceClass {
class ResolveServiceClass {
constructor(root) {
this.noteResource = Vue.resource(`${root}/notes{/noteId}/resolve`);
this.discussionResource = Vue.resource(`${root}/merge_requests{/mergeRequestId}/discussions{/discussionId}/resolve`);
......@@ -78,7 +77,6 @@ Vue.use(VueResource);
discussionId
}, {});
}
}
}
gl.DiffNotesResolveServiceClass = ResolveServiceClass;
})();
gl.DiffNotesResolveServiceClass = ResolveServiceClass;
......@@ -3,8 +3,7 @@
import Vue from 'vue';
((w) => {
w.CommentsStore = {
window.CommentsStore = {
state: {},
get: function (discussionId, noteId) {
return this.state[discussionId].getNote(noteId);
......@@ -54,5 +53,4 @@ import Vue from 'vue';
return ids;
}
};
})(window);
};
......@@ -5,8 +5,7 @@ require('~/diff_notes/models/discussion');
require('~/diff_notes/models/note');
require('~/diff_notes/stores/comments');
(() => {
function createDiscussion(noteId = 1, resolved = true) {
function createDiscussion(noteId = 1, resolved = true) {
CommentsStore.create({
discussionId: 'a',
noteId,
......@@ -17,13 +16,13 @@ require('~/diff_notes/stores/comments');
authorAvatar: 'test',
noteTruncated: 'test...',
});
}
}
beforeEach(() => {
beforeEach(() => {
CommentsStore.state = {};
});
});
describe('New discussion', () => {
describe('New discussion', () => {
it('creates new discussion', () => {
expect(Object.keys(CommentsStore.state).length).toBe(0);
createDiscussion();
......@@ -37,9 +36,9 @@ require('~/diff_notes/stores/comments');
const discussion = CommentsStore.state['a'];
expect(Object.keys(discussion.notes).length).toBe(2);
});
});
});
describe('Get note', () => {
describe('Get note', () => {
beforeEach(() => {
expect(Object.keys(CommentsStore.state).length).toBe(0);
createDiscussion();
......@@ -50,9 +49,9 @@ require('~/diff_notes/stores/comments');
expect(note).toBeDefined();
expect(note.id).toBe(1);
});
});
});
describe('Delete discussion', () => {
describe('Delete discussion', () => {
beforeEach(() => {
expect(Object.keys(CommentsStore.state).length).toBe(0);
createDiscussion();
......@@ -73,9 +72,9 @@ require('~/diff_notes/stores/comments');
CommentsStore.delete('a', 2);
expect(Object.keys(CommentsStore.state).length).toBe(0);
});
});
});
describe('Update note', () => {
describe('Update note', () => {
beforeEach(() => {
expect(Object.keys(CommentsStore.state).length).toBe(0);
createDiscussion();
......@@ -87,9 +86,9 @@ require('~/diff_notes/stores/comments');
const note = CommentsStore.get('a', 1);
expect(note.resolved).toBe(false);
});
});
});
describe('Discussion resolved', () => {
describe('Discussion resolved', () => {
beforeEach(() => {
expect(Object.keys(CommentsStore.state).length).toBe(0);
createDiscussion();
......@@ -129,5 +128,4 @@ require('~/diff_notes/stores/comments');
discussion.unResolveAllNotes();
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