New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Merge multiple responses #4112
Feature: Merge multiple responses #4112
Conversation
You've signed the CLA, adrapereira. Thank you! This pull request is ready for review. |
const selectedPosts = this.get('selectedPosts'); | ||
let canDelete = true; | ||
selectedPosts.forEach(function(p) { | ||
if (!canDelete || !p.get('can_delete')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can leave out the first part of this condition here.
Hi @adrapereira ! Thank you for the PR :) Are you able to add some tests to make sure |
post_ids: selectedPosts.map(function(p) { return p.get('id'); }), | ||
reply_post_ids: selectedReplies.map(function(p) { return p.get('id'); }) | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we're not updating the client and handling errors on the ajax call here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tgxworld The client is updated. 😃 There's no error handling in the AJAX call since the other AJAX calls didn't have it either. Can you point me to an example of how it should be handled in Discourse?
@tgxworld if this still looks good, can we merge it in? |
@coding-horror Not yet, I still need to add some tests. |
@tgxworld I've added some tests to PostMerger. Please let me know if you need anything more. |
if (result) { | ||
const selectedPosts = this.get('selectedPosts'); | ||
|
||
Discourse.Post.mergePosts(selectedPosts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's import the Post
model instead.
import Post from 'discourse/models/post';
@adrapereira Sorry for the late reply. I've left some comments after having a second look :) |
@adrapereira branch is in conflict state now, can you rebase? |
… the last response.
b853f0f
to
1058bb8
Compare
This seems in good shape if you can rebate? |
I think this is ready for merge. |
Closing in favor of #4346 |
This feature was requested in meta here.
It adds a button to a topic's administration menu enabling the admin to merge 2 or more posts by the same user.
Necessary conditions to merge posts:
There's no additional logic to account for posts that are replies to other responses, all posts will be merged in the same way, chronologically, with two new lines between each one.
The merged content will be edited into the last selected posts while the remaining responses will be marked as deleted.