Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6537a4a8
Commit
6537a4a8
authored
Jul 26, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly resolves/unresolves discussions
parent
c926cdfa
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
145 additions
and
87 deletions
+145
-87
app/assets/javascripts/diff_notes/components/resolve_all_btn.js.es6
.../javascripts/diff_notes/components/resolve_all_btn.js.es6
+16
-4
app/assets/javascripts/diff_notes/components/resolve_btn.js.es6
...sets/javascripts/diff_notes/components/resolve_btn.js.es6
+24
-7
app/assets/javascripts/diff_notes/components/resolve_count.js.es6
...ts/javascripts/diff_notes/components/resolve_count.js.es6
+0
-0
app/assets/javascripts/diff_notes/diff_notes_bundle.js.es6
app/assets/javascripts/diff_notes/diff_notes_bundle.js.es6
+3
-2
app/assets/javascripts/diff_notes/mixins/namespace.js.es6
app/assets/javascripts/diff_notes/mixins/namespace.js.es6
+9
-0
app/assets/javascripts/diff_notes/services/resolve.js.es6
app/assets/javascripts/diff_notes/services/resolve.js.es6
+60
-0
app/assets/javascripts/diff_notes/stores/comments.js.es6
app/assets/javascripts/diff_notes/stores/comments.js.es6
+20
-0
app/assets/javascripts/line_comments/services/resolve.js.es6
app/assets/javascripts/line_comments/services/resolve.js.es6
+0
-64
app/assets/javascripts/merge_request_tabs.js
app/assets/javascripts/merge_request_tabs.js
+2
-2
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+2
-2
app/views/discussions/_resolve_all.html.haml
app/views/discussions/_resolve_all.html.haml
+3
-1
app/views/projects/merge_requests/_show.html.haml
app/views/projects/merge_requests/_show.html.haml
+2
-2
app/views/projects/notes/_note.html.haml
app/views/projects/notes/_note.html.haml
+3
-2
config/application.rb
config/application.rb
+1
-1
No files found.
app/assets/javascripts/
line_comments/components/resolve_all
.js.es6
→
app/assets/javascripts/
diff_notes/components/resolve_all_btn
.js.es6
View file @
6537a4a8
((w) => {
((w) => {
w.ResolveAll = Vue.extend({
w.ResolveAllBtn = Vue.extend({
mixins: [
ButtonMixins
],
props: {
props: {
discussionId: String,
discussionId: String,
namespace: String,
mergeRequestId: Number,
namespacePath: String,
projectPath: String,
},
},
data: function() {
data: function() {
return {
return {
...
@@ -35,8 +40,15 @@
...
@@ -35,8 +40,15 @@
},
},
methods: {
methods: {
resolve: function () {
resolve: function () {
ResolveService
let promise;
.resolveAll(this.namespace, this.discussionId, this.allResolved);
if (this.allResolved) {
promise = ResolveService
.unResolveAll(this.namespace, this.mergeRequestId, this.discussionId);
} else {
promise = ResolveService
.resolveAll(this.namespace, this.mergeRequestId, this.discussionId);
}
}
}
}
}
});
});
...
...
app/assets/javascripts/
line_comment
s/components/resolve_btn.js.es6
→
app/assets/javascripts/
diff_note
s/components/resolve_btn.js.es6
View file @
6537a4a8
((w) => {
((w) => {
w.ResolveBtn = Vue.extend({
w.ResolveBtn = Vue.extend({
mixins: [
ButtonMixins
],
props: {
props: {
noteId: Number,
noteId: Number,
discussionId: String,
discussionId: String,
resolved: Boolean,
resolved: Boolean,
namespace: String
namespacePath: String,
projectPath: String,
},
},
data: function () {
data: function () {
return {
return {
...
@@ -29,11 +33,24 @@
...
@@ -29,11 +33,24 @@
.tooltip('fixTitle');
.tooltip('fixTitle');
},
},
resolve: function () {
resolve: function () {
let promise;
this.loading = true;
this.loading = true;
ResolveService
.resolve(this.namespace, this.discussionId, this.noteId, !this.isResolved)
if (this.isResolved) {
.then(() => {
promise = ResolveService
.unresolve(this.namespace, this.noteId);
} else {
promise = ResolveService
.resolve(this.namespace, this.noteId);
}
promise.then((response) => {
this.loading = false;
this.loading = false;
if (response.status === 200) {
CommentsStore.update(this.discussionId, this.noteId, !this.isResolved);
}
this.$nextTick(this.updateTooltip);
this.$nextTick(this.updateTooltip);
});
});
}
}
...
...
app/assets/javascripts/
line_comment
s/components/resolve_count.js.es6
→
app/assets/javascripts/
diff_note
s/components/resolve_count.js.es6
View file @
6537a4a8
File moved
app/assets/javascripts/
line_comments/line_comment
s_bundle.js.es6
→
app/assets/javascripts/
diff_notes/diff_note
s_bundle.js.es6
View file @
6537a4a8
...
@@ -2,14 +2,15 @@
...
@@ -2,14 +2,15 @@
//= require vue-resource
//= require vue-resource
//= require_directory ./stores
//= require_directory ./stores
//= require_directory ./services
//= require_directory ./services
//= require_directory ./mixins
//= require_directory ./components
//= require_directory ./components
$(() => {
$(() => {
window.DiffNotesApp = new Vue({
window.DiffNotesApp = new Vue({
el: '#diff-
comment
s-app',
el: '#diff-
note
s-app',
components: {
components: {
'resolve-btn': ResolveBtn,
'resolve-btn': ResolveBtn,
'resolve-all
': ResolveAll
,
'resolve-all
-btn': ResolveAllBtn
,
}
}
});
});
...
...
app/assets/javascripts/diff_notes/mixins/namespace.js.es6
0 → 100644
View file @
6537a4a8
((w) => {
w.ButtonMixins = {
computed: {
namespace: function () {
return `${this.namespacePath}/${this.projectPath}`;
}
}
};
}(window));
app/assets/javascripts/diff_notes/services/resolve.js.es6
0 → 100644
View file @
6537a4a8
((w) => {
class ResolveServiceClass {
constructor() {
this.noteResource = Vue.resource('notes{/noteId}/resolve');
this.discussionResource = Vue.resource('merge_requests{/mergeRequestId}/discussions{/discussionId}/resolve');
}
setCSRF() {
Vue.http.headers.common['X-CSRF-Token'] = $.rails.csrfToken();
}
resolve(namespace, noteId) {
this.setCSRF();
Vue.http.options.root = `/${namespace}`;
return this.noteResource.save({ noteId }, {});
}
unresolve(namespace, noteId) {
this.setCSRF();
Vue.http.options.root = `/${namespace}`;
return this.noteResource.delete({ noteId }, {});
}
resolveAll(namespace, mergeRequestId, discussionId) {
this.setCSRF();
Vue.http.options.root = `/${namespace}`;
CommentsStore.loading[discussionId] = true;
return this.discussionResource.save({
mergeRequestId,
discussionId
}, {}).then((response) => {
CommentsStore.loading[discussionId] = false;
CommentsStore.updateCommentsForDiscussion(discussionId, true);
});
}
unResolveAll(namespace, mergeRequestId, discussionId) {
this.setCSRF();
Vue.http.options.root = `/${namespace}`;
CommentsStore.loading[discussionId] = true;
return this.discussionResource.delete({
mergeRequestId,
discussionId
}, {}).then((response) => {
CommentsStore.loading[discussionId] = false;
CommentsStore.updateCommentsForDiscussion(discussionId, false);
});
}
}
w.ResolveService = new ResolveServiceClass();
}(window));
app/assets/javascripts/
line_comment
s/stores/comments.js.es6
→
app/assets/javascripts/
diff_note
s/stores/comments.js.es6
View file @
6537a4a8
...
@@ -24,5 +24,25 @@
...
@@ -24,5 +24,25 @@
Vue.delete(this.loading, discussionId);
Vue.delete(this.loading, discussionId);
}
}
},
},
updateCommentsForDiscussion: function (discussionId, resolve) {
const noteIds = CommentsStore.notesForDiscussion(discussionId, resolve);
for (const noteId of noteIds) {
CommentsStore.update(discussionId, noteId, resolve);
}
},
notesForDiscussion: function (discussionId, resolve) {
let ids = [];
for (const noteId in CommentsStore.state[discussionId]) {
const resolved = CommentsStore.state[discussionId][noteId];
if (resolved !== resolve) {
ids.push(noteId);
}
}
return ids;
}
};
};
}(window));
}(window));
app/assets/javascripts/line_comments/services/resolve.js.es6
deleted
100644 → 0
View file @
c926cdfa
((w) => {
class ResolveServiceClass {
constructor() {
const actions = {
resolve: {
method: 'POST',
url: 'notes{/id}/resolve',
},
all: {
method: 'POST',
url: 'notes/resolve_all',
}
};
this.resource = Vue.resource('notes{/id}', {}, actions);
}
setCSRF() {
Vue.http.headers.common['X-CSRF-Token'] = $.rails.csrfToken();
}
resolve(namespace, discussionId, noteId, resolve) {
this.setCSRF();
Vue.http.options.root = `/${namespace}`;
return this.resource
.resolve({ id: noteId }, { discussion: discussionId, resolved: resolve })
.then((response) => {
if (response.status === 200) {
CommentsStore.update(discussionId, noteId, resolve)
}
});
}
resolveAll(namespace, discussionId, allResolve) {
this.setCSRF();
Vue.http.options.root = `/${namespace}`;
let ids = []
for (const noteId in CommentsStore.state[discussionId]) {
const resolved = CommentsStore.state[discussionId][noteId];
if (resolved === allResolve) {
ids.push(noteId);
}
}
CommentsStore.loading[discussionId] = true;
return this.resource
.all({}, { ids: ids, discussion: discussionId, resolved: !allResolve })
.then((response) => {
if (response.status === 200) {
for (const noteId in ids) {
CommentsStore.update(discussionId, noteId, !allResolve);
}
}
CommentsStore.loading[discussionId] = false;
});
}
}
w.ResolveService = new ResolveServiceClass();
}(window));
app/assets/javascripts/merge_request_tabs.js
View file @
6537a4a8
...
@@ -120,8 +120,8 @@
...
@@ -120,8 +120,8 @@
return
function
(
data
)
{
return
function
(
data
)
{
$
(
'
#diffs
'
).
html
(
data
.
html
);
$
(
'
#diffs
'
).
html
(
data
.
html
);
if
(
$
(
'
resolve-btn, resolve-all
'
).
length
&&
(
typeof
DiffNotesApp
!==
"
undefined
"
&&
DiffNotesApp
!==
null
))
{
if
(
$
(
'
resolve-btn, resolve-all
-btn
'
).
length
&&
(
typeof
DiffNotesApp
!==
"
undefined
"
&&
DiffNotesApp
!==
null
))
{
$
(
'
resolve-btn, resolve-all
'
).
each
(
function
()
{
$
(
'
resolve-btn, resolve-all
-btn
'
).
each
(
function
()
{
DiffNotesApp
.
$compile
(
$
(
this
).
get
(
0
))
DiffNotesApp
.
$compile
(
$
(
this
).
get
(
0
))
});
});
}
}
...
...
app/assets/javascripts/notes.js
View file @
6537a4a8
...
@@ -300,8 +300,8 @@
...
@@ -300,8 +300,8 @@
discussionContainer
.
append
(
note_html
);
discussionContainer
.
append
(
note_html
);
}
}
if
(
$
(
'
resolve-btn, resolve-all
'
).
length
&&
(
typeof
DiffNotesApp
!==
"
undefined
"
&&
DiffNotesApp
!==
null
))
{
if
(
$
(
'
resolve-btn, resolve-all
-btn
'
).
length
&&
(
typeof
DiffNotesApp
!==
"
undefined
"
&&
DiffNotesApp
!==
null
))
{
$
(
'
resolve-btn, resolve-all
'
).
each
(
function
()
{
$
(
'
resolve-btn, resolve-all
-btn
'
).
each
(
function
()
{
DiffNotesApp
.
$compile
(
$
(
this
).
get
(
0
))
DiffNotesApp
.
$compile
(
$
(
this
).
get
(
0
))
});
});
}
}
...
...
app/views/discussions/_resolve_all.html.haml
View file @
6537a4a8
-
if
discussion
.
can_resolve?
(
current_user
)
-
if
discussion
.
can_resolve?
(
current_user
)
%resolve-all
{
":namespace"
=>
"'#{discussion.project.namespace.path}/#{discussion.project.path}'"
,
%resolve-all-btn
{
":namespace-path"
=>
"'#{discussion.project.namespace.path}'"
,
":project-path"
=>
"'#{discussion.project.path}'"
,
":discussion-id"
=>
"'#{discussion.id}'"
,
":discussion-id"
=>
"'#{discussion.id}'"
,
":merge-request-id"
=>
"#{discussion.first_note.noteable.iid}"
,
"inline-template"
=>
true
,
"inline-template"
=>
true
,
"v-cloak"
=>
true
}
"v-cloak"
=>
true
}
%button
.btn.btn-default
{
type:
"button"
,
"@click"
=>
"resolve"
,
":disabled"
=>
"loading"
}
%button
.btn.btn-default
{
type:
"button"
,
"@click"
=>
"resolve"
,
":disabled"
=>
"loading"
}
...
...
app/views/projects/merge_requests/_show.html.haml
View file @
6537a4a8
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
-
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_tag
(
'
line_comments/line_comment
s_bundle.js'
)
=
page_specific_javascript_tag
(
'
diff_notes/diff_note
s_bundle.js'
)
-
if
diff_view
==
'parallel'
-
if
diff_view
==
'parallel'
-
fluid_layout
true
-
fluid_layout
true
...
@@ -71,7 +71,7 @@
...
@@ -71,7 +71,7 @@
Changes
Changes
%span
.badge
=
@merge_request
.
diff_size
%span
.badge
=
@merge_request
.
diff_size
.tab-content
#diff-
comment
s-app
.tab-content
#diff-
note
s-app
#notes
.notes.tab-pane.voting_notes
#notes
.notes.tab-pane.voting_notes
.content-block.content-block-small.oneline-block
.content-block.content-block-small.oneline-block
=
render
'award_emoji/awards_block'
,
awardable:
@merge_request
,
inline:
true
=
render
'award_emoji/awards_block'
,
awardable:
@merge_request
,
inline:
true
...
...
app/views/projects/notes/_note.html.haml
View file @
6537a4a8
...
@@ -24,7 +24,8 @@
...
@@ -24,7 +24,8 @@
-
if
note
.
resolvable?
-
if
note
.
resolvable?
-
if
can?
(
current_user
,
:resolve_note
,
note
)
-
if
can?
(
current_user
,
:resolve_note
,
note
)
%resolve-btn
{
":namespace"
=>
"'#{note.project.namespace.path}/#{note.project.path}'"
,
%resolve-btn
{
":namespace-path"
=>
"'#{note.project.namespace.path}'"
,
":project-path"
=>
"'#{note.project.path}'"
,
":discussion-id"
=>
"'#{note.discussion_id}'"
,
":discussion-id"
=>
"'#{note.discussion_id}'"
,
":note-id"
=>
note
.
id
,
":note-id"
=>
note
.
id
,
":resolved"
=>
note
.
resolved?
,
":resolved"
=>
note
.
resolved?
,
...
...
config/application.rb
View file @
6537a4a8
...
@@ -85,7 +85,7 @@ module Gitlab
...
@@ -85,7 +85,7 @@ module Gitlab
config
.
assets
.
precompile
<<
"users/users_bundle.js"
config
.
assets
.
precompile
<<
"users/users_bundle.js"
config
.
assets
.
precompile
<<
"network/network_bundle.js"
config
.
assets
.
precompile
<<
"network/network_bundle.js"
config
.
assets
.
precompile
<<
"profile/profile_bundle.js"
config
.
assets
.
precompile
<<
"profile/profile_bundle.js"
config
.
assets
.
precompile
<<
"
line_comments/line_comment
s_bundle.js"
config
.
assets
.
precompile
<<
"
diff_notes/diff_note
s_bundle.js"
config
.
assets
.
precompile
<<
"lib/utils/*.js"
config
.
assets
.
precompile
<<
"lib/utils/*.js"
config
.
assets
.
precompile
<<
"lib/*.js"
config
.
assets
.
precompile
<<
"lib/*.js"
config
.
assets
.
precompile
<<
"u2f.js"
config
.
assets
.
precompile
<<
"u2f.js"
...
...
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