Commit b8ee5c18 authored by Phil Hughes's avatar Phil Hughes

Fixed failing diff notes vue tests

parent 87b4ccd1
...@@ -17,6 +17,7 @@ const Vue = require('vue'); ...@@ -17,6 +17,7 @@ const Vue = require('vue');
}, },
data: function () { data: function () {
return { return {
note: {},
discussions: CommentsStore.state, discussions: CommentsStore.state,
loading: false loading: false
}; };
...@@ -31,13 +32,6 @@ const Vue = require('vue'); ...@@ -31,13 +32,6 @@ const Vue = require('vue');
discussion: function () { discussion: function () {
return this.discussions[this.discussionId]; return this.discussions[this.discussionId];
}, },
note: function () {
if (this.discussion) {
return this.discussion.getNote(this.noteId);
} else {
return undefined;
}
},
buttonText: function () { buttonText: function () {
if (this.isResolved) { if (this.isResolved) {
return `Resolved by ${this.resolvedByName}`; return `Resolved by ${this.resolvedByName}`;
...@@ -107,6 +101,8 @@ const Vue = require('vue'); ...@@ -107,6 +101,8 @@ const Vue = require('vue');
}, },
created: function () { created: function () {
CommentsStore.create(this.discussionId, this.noteId, this.canResolve, this.resolved, this.resolvedBy); CommentsStore.create(this.discussionId, this.noteId, this.canResolve, this.resolved, this.resolvedBy);
this.note = this.discussion.getNote(this.noteId);
} }
}); });
......
...@@ -14,13 +14,11 @@ const Vue = require('vue'); ...@@ -14,13 +14,11 @@ const Vue = require('vue');
}, },
data: function() { data: function() {
return { return {
discussions: CommentsStore.state discussions: CommentsStore.state,
discussion: {},
}; };
}, },
computed: { computed: {
discussion: function () {
return this.discussions[this.discussionId];
},
showButton: function () { showButton: function () {
if (this.discussion) { if (this.discussion) {
return this.discussion.isResolvable(); return this.discussion.isResolvable();
...@@ -57,6 +55,8 @@ const Vue = require('vue'); ...@@ -57,6 +55,8 @@ const Vue = require('vue');
}, },
created: function () { created: function () {
CommentsStore.createDiscussion(this.discussionId, this.canResolve); CommentsStore.createDiscussion(this.discussionId, this.canResolve);
this.discussion = this.discussions[this.discussionId]
} }
}); });
......
...@@ -11,11 +11,14 @@ requireAll(require.context('./mixins', false, /^\.\/.*\.(js|es6)$/)); ...@@ -11,11 +11,14 @@ requireAll(require.context('./mixins', false, /^\.\/.*\.(js|es6)$/));
requireAll(require.context('./components', false, /^\.\/.*\.(js|es6)$/)); requireAll(require.context('./components', false, /^\.\/.*\.(js|es6)$/));
$(() => { $(() => {
const projectPath = document.querySelector('.merge-request').dataset.projectPath;
const COMPONENT_SELECTOR = 'resolve-btn, resolve-discussion-btn, jump-to-discussion, comment-and-resolve-btn'; const COMPONENT_SELECTOR = 'resolve-btn, resolve-discussion-btn, jump-to-discussion, comment-and-resolve-btn';
window.gl = window.gl || {}; window.gl = window.gl || {};
window.gl.diffNoteApps = {}; window.gl.diffNoteApps = {};
window.ResolveService = new ResolveServiceClass(projectPath);
gl.diffNotesCompileComponents = () => { gl.diffNotesCompileComponents = () => {
const $components = $(COMPONENT_SELECTOR).filter(function () { const $components = $(COMPONENT_SELECTOR).filter(function () {
return $(this).closest('resolve-count').length !== 1; return $(this).closest('resolve-count').length !== 1;
...@@ -45,6 +48,6 @@ $(() => { ...@@ -45,6 +48,6 @@ $(() => {
el: '#resolve-count-app', el: '#resolve-count-app',
components: { components: {
'resolve-count': ResolveCount 'resolve-count': ResolveCount
} },
}); });
}); });
...@@ -3,20 +3,21 @@ ...@@ -3,20 +3,21 @@
/* global Flash */ /* global Flash */
/* global CommentsStore */ /* global CommentsStore */
((w) => { window.Vue.use(require('vue-resource'));
class ResolveServiceClass {
constructor() { (() => {
this.noteResource = Vue.resource('notes{/noteId}/resolve'); window.ResolveServiceClass = class ResolveServiceClass {
this.discussionResource = Vue.resource('merge_requests{/mergeRequestId}/discussions{/discussionId}/resolve'); constructor(rootPath) {
this.noteResource = Vue.resource(`${rootPath}/notes{/noteId}/resolve`);
this.discussionResource = Vue.resource(`${rootPath}/merge_requests{/mergeRequestId}/discussions{/discussionId}/resolve`);
} }
setCSRF() { setCSRF() {
Vue.http.headers.common['X-CSRF-Token'] = $.rails.csrfToken(); Vue.http.headers.common['X-CSRF-Token'] = $.rails.csrfToken();
} }
prepareRequest(root) { prepareRequest() {
this.setCSRF(); this.setCSRF();
Vue.http.options.root = root;
} }
resolve(projectPath, noteId) { resolve(projectPath, noteId) {
...@@ -88,6 +89,4 @@ ...@@ -88,6 +89,4 @@
}, {}); }, {});
} }
} }
})();
w.ResolveService = new ResolveServiceClass();
})(window);
...@@ -3,10 +3,9 @@ ...@@ -3,10 +3,9 @@
- page_description @merge_request.description - page_description @merge_request.description
- page_card_attributes @merge_request.card_attributes - page_card_attributes @merge_request.card_attributes
- content_for :page_specific_javascripts do - content_for :page_specific_javascripts do
= page_specific_javascript_bundle_tag('lib_vue')
= page_specific_javascript_bundle_tag('diff_notes') = page_specific_javascript_bundle_tag('diff_notes')
.merge-request{ 'data-url' => merge_request_path(@merge_request) } .merge-request{ 'data-url' => merge_request_path(@merge_request), 'data-project-path' => project_path(@merge_request.project) }
= render "projects/merge_requests/show/mr_title" = render "projects/merge_requests/show/mr_title"
.merge-request-details.issuable-details{ data: { id: @merge_request.project.id } } .merge-request-details.issuable-details{ data: { id: @merge_request.project.id } }
......
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