Skip to content

A platform for community discussion. Free, open, simple.

FIX: post voting comments editing UX (#35108)

Régis Hanole171530e14bc
diff --git a/plugins/discourse-post-voting/assets/javascripts/discourse/components/post-voting-comment-actions.gjs b/plugins/discourse-post-voting/assets/javascripts/discourse/components/post-voting-comment-actions.gjs
index 1f73200b5cf..67d5953fbe7 100644
--- a/plugins/discourse-post-voting/assets/javascripts/discourse/components/post-voting-comment-actions.gjs
+++ b/plugins/discourse-post-voting/assets/javascripts/discourse/components/post-voting-comment-actions.gjs
@@ -16,7 +16,7 @@ export default class PostVotingCommentActions extends Component {
comment = this.args.comment;
- hasPermission() {
+ get hasPermission() {
return (
this.comment.user_id === this.currentUser.id ||
this.currentUser.admin ||
@@ -83,7 +83,6 @@ export default class PostVotingCommentActions extends Component {
@action={{this.deleteConfirm}}
@icon="far-trash-can"
/>
-
{{#if this.canFlag}}
<DButton
@display="link"
diff --git a/plugins/discourse-post-voting/test/javascripts/acceptance/post-voting-test.js b/plugins/discourse-post-voting/test/javascripts/acceptance/post-voting-test.js
index 62fec9ca6c0..fabddf151bc 100644
--- a/plugins/discourse-post-voting/test/javascripts/acceptance/post-voting-test.js
+++ b/plugins/discourse-post-voting/test/javascripts/acceptance/post-voting-test.js
@@ -231,6 +231,10 @@ function setupPostVoting(needs, postStreamMode) {
"displays the right number of comments for the second post"
);
+ assert
+ .dom("#post_2 .post-voting-comment-action")
+ .doesNotExist("does not display comment action to anon users");
+
await click(".post-voting-comments-menu-show-more-link");
assert
@@ -494,6 +498,44 @@ function setupPostVoting(needs, postStreamMode) {
.exists({ count: 3 }, "should add the new comment");
});
+ test("regular user can't edit other people's comments", async function (assert) {
+ updateCurrentUser({ id: 9876, admin: false, moderator: false }); // hasn't commented
+
+ await visit("/t/280");
+
+ assert
+ .dom("#post_2 .post-voting-comment-actions")
+ .doesNotExist(
+ "does not display edit link on other people's comments"
+ );
+ });
+
+ test("moderator can edit other people's comments", async function (assert) {
+ updateCurrentUser({ id: 9876, admin: false, moderator: true }); // hasn't commented
+
+ await visit("/t/280");
+
+ assert
+ .dom("#post_2 .post-voting-comment-actions")
+ .exists(
+ { count: 5 },
+ "displays edit link on other people's comments"
+ );
+ });
+
+ test("admin can edit other people's comments", async function (assert) {
+ updateCurrentUser({ id: 9876, admin: true, moderator: false }); // hasn't commented
+
+ await visit("/t/280");
+
+ assert
+ .dom("#post_2 .post-voting-comment-actions")
+ .exists(
+ { count: 5 },
+ "displays edit link on other people's comments"
+ );
+ });
+
test("editing a comment", async function (assert) {
updateCurrentUser({ id: 12345 }); // userId of comments in fixtures