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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
ee62a2fd
Commit
ee62a2fd
authored
Aug 01, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved update headline HTML into discussion model
parent
d6e724d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
42 deletions
+45
-42
app/assets/javascripts/diff_notes/components/resolve_btn.js.es6
...sets/javascripts/diff_notes/components/resolve_btn.js.es6
+5
-2
app/assets/javascripts/diff_notes/models/discussion.js.es6
app/assets/javascripts/diff_notes/models/discussion.js.es6
+14
-0
app/assets/javascripts/diff_notes/services/resolve.js.es6
app/assets/javascripts/diff_notes/services/resolve.js.es6
+26
-40
No files found.
app/assets/javascripts/diff_notes/components/resolve_btn.js.es6
View file @
ee62a2fd
...
...
@@ -25,6 +25,9 @@
}
},
computed: {
discussion: function () {
return this.discussions[this.discussionId];
},
note: function () {
return CommentsStore.get(this.discussionId, this.noteId);
},
...
...
@@ -63,14 +66,14 @@
}
promise.then((response) => {
const data = response.json();
this.loading = false;
if (response.status === 200) {
const data = response.json();
const resolved_by = data ? data.resolved_by : null;
CommentsStore.update(this.discussionId, this.noteId, !this.isResolved, resolved_by);
ResolveService.updateDiscussionHeadline(this.discussionId,
data);
this.discussion.updateHeadline(
data);
} else {
new Flash('An error occurred when trying to resolve a comment. Please try again.', 'alert');
}
...
...
app/assets/javascripts/diff_notes/models/discussion.js.es6
View file @
ee62a2fd
...
...
@@ -53,4 +53,18 @@ class DiscussionModel {
}
}
}
updateHeadline (data) {
const $discussionHeadline = $(`.discussion[data-discussion-id="${this.id}"] .js-discussion-headline`);
if (data.discussion_headline_html) {
if ($discussionHeadline.length) {
$discussionHeadline.replaceWith(data.discussion_headline_html);
} else {
$(`.discussion[data-discussion-id="${this.id}"] .discussion-header`).append(data.discussion_headline_html);
}
} else {
$discussionHeadline.remove();
}
}
}
app/assets/javascripts/diff_notes/services/resolve.js.es6
View file @
ee62a2fd
...
...
@@ -28,13 +28,34 @@
}
toggleResolveForDiscussion(namespace, mergeRequestId, discussionId) {
const isResolved = CommentsStore.state[discussionId].isResolved();
const discussion = CommentsStore.state[discussionId],
isResolved = discussion.isResolved();
let promise;
if (isResolved) {
return
this.unResolveAll(namespace, mergeRequestId, discussionId);
promise =
this.unResolveAll(namespace, mergeRequestId, discussionId);
} else {
return
this.resolveAll(namespace, mergeRequestId, discussionId);
promise =
this.resolveAll(namespace, mergeRequestId, discussionId);
}
promise.then((response) => {
discussion.loading = false;
if (response.status === 200) {
const data = response.json();
const resolved_by = data ? data.resolved_by : null;
if (isResolved) {
discussion.unResolveAllNotes();
} else {
discussion.resolveAllNotes(resolved_by);
}
discussion.updateHeadline(data);
} else {
new Flash('An error occurred when trying to resolve a discussion. Please try again.', 'alert');
}
})
}
resolveAll(namespace, mergeRequestId, discussionId) {
...
...
@@ -51,18 +72,7 @@
return this.discussionResource.save({
mergeRequestId,
discussionId
}, {}).then((response) => {
if (response.status === 200) {
const data = response.json();
const resolved_by = data ? data.resolved_by : null;
discussion.resolveAllNotes(resolved_by);
discussion.loading = false;
this.updateDiscussionHeadline(discussionId, data);
} else {
new Flash('An error occurred when trying to resolve a discussion. Please try again.', 'alert');
}
});
}, {});
}
unResolveAll(namespace, mergeRequestId, discussionId) {
...
...
@@ -76,31 +86,7 @@
return this.discussionResource.delete({
mergeRequestId,
discussionId
}, {}).then((response) => {
if (response.status === 200) {
const data = response.json();
discussion.unResolveAllNotes();
discussion.loading = false;
this.updateDiscussionHeadline(discussionId, data);
} else {
new Flash('An error occurred when trying to unresolve a discussion. Please try again.', 'alert');
}
});
}
updateDiscussionHeadline(discussionId, data) {
const $discussionHeadline = $(`.discussion[data-discussion-id="${discussionId}"] .js-discussion-headline`);
if (data.discussion_headline_html) {
if ($discussionHeadline.length) {
$discussionHeadline.replaceWith(data.discussion_headline_html);
} else {
$(`.discussion[data-discussion-id="${discussionId}"] .discussion-header`).append(data.discussion_headline_html);
}
} else {
$discussionHeadline.remove();
}
}, {});
}
}
...
...
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