BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
f9c58d93
Commit
f9c58d93
authored
Feb 08, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored diff notes Vue app
It now relies on its Vue bundle rather than the window. Fixes some reactivity issues that was happening in EE
parent
4975f416
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
57 additions
and
66 deletions
+57
-66
comment_resolve_btn.js.es6
...ascripts/diff_notes/components/comment_resolve_btn.js.es6
+6
-5
jump_to_discussion.js.es6
...vascripts/diff_notes/components/jump_to_discussion.js.es6
+6
-5
resolve_btn.js.es6
...sets/javascripts/diff_notes/components/resolve_btn.js.es6
+7
-12
resolve_count.js.es6
...ts/javascripts/diff_notes/components/resolve_count.js.es6
+1
-1
resolve_discussion_btn.js.es6
...ripts/diff_notes/components/resolve_discussion_btn.js.es6
+6
-7
diff_notes_bundle.js.es6
app/assets/javascripts/diff_notes/diff_notes_bundle.js.es6
+4
-0
resolve.js.es6
app/assets/javascripts/diff_notes/services/resolve.js.es6
+23
-29
notes.js
app/assets/javascripts/notes.js
+1
-1
_resolve_all.html.haml
app/views/discussions/_resolve_all.html.haml
+1
-2
_show.html.haml
app/views/projects/merge_requests/_show.html.haml
+1
-2
_note.html.haml
app/views/projects/notes/_note.html.haml
+1
-2
No files found.
app/assets/javascripts/diff_notes/components/comment_resolve_btn.js.es6
View file @
f9c58d93
/* eslint-disable comma-dangle, object-shorthand, func-names, no-else-return, quotes, no-lonely-if, max-len */
/* eslint-disable comma-dangle, object-shorthand, func-names, no-else-return, quotes, no-lonely-if, max-len */
/* global Vue */
/* global CommentsStore */
/* global CommentsStore */
const Vue = require('vue');
(() => {
(() => {
const CommentAndResolveBtn = Vue.extend({
const CommentAndResolveBtn = Vue.extend({
...
@@ -9,13 +9,11 @@
...
@@ -9,13 +9,11 @@
},
},
data() {
data() {
return {
return {
textareaIsEmpty: true
textareaIsEmpty: true,
discussion: {},
};
};
},
},
computed: {
computed: {
discussion: function () {
return CommentsStore.state[this.discussionId];
},
showButton: function () {
showButton: function () {
if (this.discussion) {
if (this.discussion) {
return this.discussion.isResolvable();
return this.discussion.isResolvable();
...
@@ -42,6 +40,9 @@
...
@@ -42,6 +40,9 @@
}
}
}
}
},
},
created() {
this.discussion = CommentsStore.state[this.discussionId];
},
mounted: function () {
mounted: function () {
const $textarea = $(`#new-discussion-note-form-${this.discussionId} .note-textarea`);
const $textarea = $(`#new-discussion-note-form-${this.discussionId} .note-textarea`);
this.textareaIsEmpty = $textarea.val() === '';
this.textareaIsEmpty = $textarea.val() === '';
...
...
app/assets/javascripts/diff_notes/components/jump_to_discussion.js.es6
View file @
f9c58d93
/* eslint-disable comma-dangle, object-shorthand, func-names, no-else-return, guard-for-in, no-restricted-syntax, one-var, space-before-function-paren, no-lonely-if, no-continue, brace-style, max-len, quotes */
/* eslint-disable comma-dangle, object-shorthand, func-names, no-else-return, guard-for-in, no-restricted-syntax, one-var, space-before-function-paren, no-lonely-if, no-continue, brace-style, max-len, quotes */
/* global Vue */
/* global DiscussionMixins */
/* global DiscussionMixins */
/* global CommentsStore */
/* global CommentsStore */
const Vue = require('vue');
(() => {
(() => {
const JumpToDiscussion = Vue.extend({
const JumpToDiscussion = Vue.extend({
...
@@ -12,12 +12,10 @@
...
@@ -12,12 +12,10 @@
data: function () {
data: function () {
return {
return {
discussions: CommentsStore.state,
discussions: CommentsStore.state,
discussion: {},
};
};
},
},
computed: {
computed: {
discussion: function () {
return this.discussions[this.discussionId];
},
allResolved: function () {
allResolved: function () {
return this.unresolvedDiscussionCount === 0;
return this.unresolvedDiscussionCount === 0;
},
},
...
@@ -186,7 +184,10 @@
...
@@ -186,7 +184,10 @@
offset: -($('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight())
offset: -($('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight())
});
});
}
}
}
},
created() {
this.discussion = this.discussions[this.discussionId];
},
});
});
Vue.component('jump-to-discussion', JumpToDiscussion);
Vue.component('jump-to-discussion', JumpToDiscussion);
...
...
app/assets/javascripts/diff_notes/components/resolve_btn.js.es6
View file @
f9c58d93
/* eslint-disable comma-dangle, object-shorthand, func-names, quote-props, no-else-return, camelcase, no-new, max-len */
/* eslint-disable comma-dangle, object-shorthand, func-names, quote-props, no-else-return, camelcase, no-new, max-len */
/* global Vue */
/* global CommentsStore */
/* global CommentsStore */
/* global ResolveService */
/* global ResolveService */
/* global Flash */
/* global Flash */
const Vue = require('vue');
(() => {
(() => {
const ResolveBtn = Vue.extend({
const ResolveBtn = Vue.extend({
...
@@ -10,14 +10,14 @@
...
@@ -10,14 +10,14 @@
noteId: Number,
noteId: Number,
discussionId: String,
discussionId: String,
resolved: Boolean,
resolved: Boolean,
projectPath: String,
canResolve: Boolean,
canResolve: Boolean,
resolvedBy: String
resolvedBy: String
},
},
data: function () {
data: function () {
return {
return {
discussions: CommentsStore.state,
discussions: CommentsStore.state,
loading: false
loading: false,
note: {},
};
};
},
},
watch: {
watch: {
...
@@ -30,13 +30,6 @@
...
@@ -30,13 +30,6 @@
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}`;
...
@@ -73,10 +66,10 @@
...
@@ -73,10 +66,10 @@
if (this.isResolved) {
if (this.isResolved) {
promise = ResolveService
promise = ResolveService
.unresolve(this.
projectPath, this.
noteId);
.unresolve(this.noteId);
} else {
} else {
promise = ResolveService
promise = ResolveService
.resolve(this.
projectPath, this.
noteId);
.resolve(this.noteId);
}
}
promise.then((response) => {
promise.then((response) => {
...
@@ -106,6 +99,8 @@
...
@@ -106,6 +99,8 @@
},
},
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);
}
}
});
});
...
...
app/assets/javascripts/diff_notes/components/resolve_count.js.es6
View file @
f9c58d93
/* eslint-disable comma-dangle, object-shorthand, func-names, no-param-reassign */
/* eslint-disable comma-dangle, object-shorthand, func-names, no-param-reassign */
/* global Vue */
/* global DiscussionMixins */
/* global DiscussionMixins */
/* global CommentsStore */
/* global CommentsStore */
const Vue = require('vue');
((w) => {
((w) => {
w.ResolveCount = Vue.extend({
w.ResolveCount = Vue.extend({
...
...
app/assets/javascripts/diff_notes/components/resolve_discussion_btn.js.es6
View file @
f9c58d93
/* eslint-disable object-shorthand, func-names, space-before-function-paren, comma-dangle, no-else-return, quotes, max-len */
/* eslint-disable object-shorthand, func-names, space-before-function-paren, comma-dangle, no-else-return, quotes, max-len */
/* global Vue */
/* global CommentsStore */
/* global CommentsStore */
/* global ResolveService */
/* global ResolveService */
const Vue = require('vue');
(() => {
(() => {
const ResolveDiscussionBtn = Vue.extend({
const ResolveDiscussionBtn = Vue.extend({
props: {
props: {
discussionId: String,
discussionId: String,
mergeRequestId: Number,
mergeRequestId: Number,
projectPath: String,
canResolve: Boolean,
canResolve: Boolean,
},
},
data: function() {
data: function() {
return {
return {
discussion
s: 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();
...
@@ -51,11 +48,13 @@
...
@@ -51,11 +48,13 @@
},
},
methods: {
methods: {
resolve: function () {
resolve: function () {
ResolveService.toggleResolveForDiscussion(this.
projectPath, this.
mergeRequestId, this.discussionId);
ResolveService.toggleResolveForDiscussion(this.mergeRequestId, this.discussionId);
}
}
},
},
created: function () {
created: function () {
CommentsStore.createDiscussion(this.discussionId, this.canResolve);
CommentsStore.createDiscussion(this.discussionId, this.canResolve);
this.discussion = CommentsStore.state[this.discussionId];
}
}
});
});
...
...
app/assets/javascripts/diff_notes/diff_notes_bundle.js.es6
View file @
f9c58d93
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
/* global ResolveCount */
/* global ResolveCount */
function requireAll(context) { return context.keys().map(context); }
function requireAll(context) { return context.keys().map(context); }
const Vue = require('vue');
requireAll(require.context('./models', false, /^\.\/.*\.(js|es6)$/));
requireAll(require.context('./models', false, /^\.\/.*\.(js|es6)$/));
requireAll(require.context('./stores', false, /^\.\/.*\.(js|es6)$/));
requireAll(require.context('./stores', false, /^\.\/.*\.(js|es6)$/));
requireAll(require.context('./services', false, /^\.\/.*\.(js|es6)$/));
requireAll(require.context('./services', false, /^\.\/.*\.(js|es6)$/));
...
@@ -10,11 +11,14 @@ requireAll(require.context('./mixins', false, /^\.\/.*\.(js|es6)$/));
...
@@ -10,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 gl.DiffNotesResolveServiceClass(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;
...
...
app/assets/javascripts/diff_notes/services/resolve.js.es6
View file @
f9c58d93
/* eslint-disable class-methods-use-this, one-var, camelcase, no-new, comma-dangle, no-param-reassign, max-len */
/* eslint-disable class-methods-use-this, one-var, camelcase, no-new, comma-dangle, no-param-reassign, max-len */
/* global Vue */
/* global Flash */
/* global Flash */
/* global CommentsStore */
/* global CommentsStore */
((w) => {
const Vue = window.Vue = require('vue');
window.Vue.use(require('vue-resource'));
(() => {
window.gl = window.gl || {};
class ResolveServiceClass {
class ResolveServiceClass {
constructor() {
constructor(root) {
this.noteResource = Vue.resource('notes{/noteId}/resolve');
this.noteResource = Vue.resource(`${root}/notes{/noteId}/resolve`);
this.discussionResource = Vue.resource('merge_requests{/mergeRequestId}/discussions{/discussionId}/resolve');
this.discussionResource = Vue.resource(`${root}/merge_requests{/mergeRequestId}/discussions{/discussionId}/resolve`);
}
setCSRF() {
Vue.http.interceptors.push((request, next) => {
Vue.http.headers.common['X-CSRF-Token'] = $.rails.csrfToken();
if ($.rails) {
request.headers['X-CSRF-Token'] = $.rails.csrfToken();
}
}
next();
prepareRequest(root) {
});
this.setCSRF();
Vue.http.options.root = root;
}
}
resolve(projectPath, noteId) {
resolve(noteId) {
this.prepareRequest(projectPath);
return this.noteResource.save({ noteId }, {});
return this.noteResource.save({ noteId }, {});
}
}
unresolve(projectPath, noteId) {
unresolve(noteId) {
this.prepareRequest(projectPath);
return this.noteResource.delete({ noteId }, {});
return this.noteResource.delete({ noteId }, {});
}
}
toggleResolveForDiscussion(
projectPath,
mergeRequestId, discussionId) {
toggleResolveForDiscussion(mergeRequestId, discussionId) {
const discussion = CommentsStore.state[discussionId];
const discussion = CommentsStore.state[discussionId];
const isResolved = discussion.isResolved();
const isResolved = discussion.isResolved();
let promise;
let promise;
if (isResolved) {
if (isResolved) {
promise = this.unResolveAll(
projectPath,
mergeRequestId, discussionId);
promise = this.unResolveAll(mergeRequestId, discussionId);
} else {
} else {
promise = this.resolveAll(
projectPath,
mergeRequestId, discussionId);
promise = this.resolveAll(mergeRequestId, discussionId);
}
}
promise.then((response) => {
promise.then((response) => {
...
@@ -62,11 +60,9 @@
...
@@ -62,11 +60,9 @@
});
});
}
}
resolveAll(
projectPath,
mergeRequestId, discussionId) {
resolveAll(mergeRequestId, discussionId) {
const discussion = CommentsStore.state[discussionId];
const discussion = CommentsStore.state[discussionId];
this.prepareRequest(projectPath);
discussion.loading = true;
discussion.loading = true;
return this.discussionResource.save({
return this.discussionResource.save({
...
@@ -75,11 +71,9 @@
...
@@ -75,11 +71,9 @@
}, {});
}, {});
}
}
unResolveAll(
projectPath,
mergeRequestId, discussionId) {
unResolveAll(mergeRequestId, discussionId) {
const discussion = CommentsStore.state[discussionId];
const discussion = CommentsStore.state[discussionId];
this.prepareRequest(projectPath);
discussion.loading = true;
discussion.loading = true;
return this.discussionResource.delete({
return this.discussionResource.delete({
...
@@ -89,5 +83,5 @@
...
@@ -89,5 +83,5 @@
}
}
}
}
w.ResolveService = new ResolveServiceClass()
;
gl.DiffNotesResolveServiceClass = ResolveServiceClass
;
})(
window
);
})();
app/assets/javascripts/notes.js
View file @
f9c58d93
...
@@ -455,7 +455,7 @@ require('vendor/task_list');
...
@@ -455,7 +455,7 @@ require('vendor/task_list');
var
mergeRequestId
=
$form
.
data
(
'noteable-iid'
);
var
mergeRequestId
=
$form
.
data
(
'noteable-iid'
);
if
(
ResolveService
!=
null
)
{
if
(
ResolveService
!=
null
)
{
ResolveService
.
toggleResolveForDiscussion
(
projectPath
,
mergeRequestId
,
discussionId
);
ResolveService
.
toggleResolveForDiscussion
(
mergeRequestId
,
discussionId
);
}
}
}
}
...
...
app/views/discussions/_resolve_all.html.haml
View file @
f9c58d93
-
if
discussion
.
for_merge_request?
-
if
discussion
.
for_merge_request?
%resolve-discussion-btn
{
":project-path"
=>
"'#{project_path(discussion.project)}'"
,
%resolve-discussion-btn
{
":discussion-id"
=>
"'#{discussion.id}'"
,
":discussion-id"
=>
"'#{discussion.id}'"
,
":merge-request-id"
=>
discussion
.
noteable
.
iid
,
":merge-request-id"
=>
discussion
.
noteable
.
iid
,
":can-resolve"
=>
discussion
.
can_resolve?
(
current_user
),
":can-resolve"
=>
discussion
.
can_resolve?
(
current_user
),
"inline-template"
=>
true
}
"inline-template"
=>
true
}
...
...
app/views/projects/merge_requests/_show.html.haml
View file @
f9c58d93
...
@@ -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
}
}
...
...
app/views/projects/notes/_note.html.haml
View file @
f9c58d93
...
@@ -30,8 +30,7 @@
...
@@ -30,8 +30,7 @@
-
if
note
.
resolvable?
-
if
note
.
resolvable?
-
can_resolve
=
can?
(
current_user
,
:resolve_note
,
note
)
-
can_resolve
=
can?
(
current_user
,
:resolve_note
,
note
)
%resolve-btn
{
"project-path"
=>
"#{project_path(note.project)}"
,
%resolve-btn
{
"discussion-id"
=>
"#{note.discussion_id}"
,
"discussion-id"
=>
"#{note.discussion_id}"
,
":note-id"
=>
note
.
id
,
":note-id"
=>
note
.
id
,
":resolved"
=>
note
.
resolved?
,
":resolved"
=>
note
.
resolved?
,
":can-resolve"
=>
can_resolve
,
":can-resolve"
=>
can_resolve
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment