From 7a9e85b1d7a33b2876248b3e2f566606b87a6b00 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 30 May 2019 13:31:40 -0400 Subject: [PATCH] FIX: Don't show the "Flag to delete" message to staff If they can't delete, flagging should not either. --- .../javascripts/discourse/lib/transform-post.js.es6 | 10 ++++++++++ .../javascripts/discourse/widgets/post-menu.js.es6 | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/lib/transform-post.js.es6 b/app/assets/javascripts/discourse/lib/transform-post.js.es6 index 90693c3dcee..4aad29a3026 100644 --- a/app/assets/javascripts/discourse/lib/transform-post.js.es6 +++ b/app/assets/javascripts/discourse/lib/transform-post.js.es6 @@ -45,6 +45,7 @@ export function transformBasicPost(post) { created_at: post.created_at, updated_at: post.updated_at, canDelete: post.can_delete, + showFlagDelete: false, canRecover: post.can_recover, canEdit: post.can_edit, canFlag: !Ember.isEmpty(post.get("flagsAvailable")), @@ -230,6 +231,15 @@ export default function transformPost( postAtts.canRecoverTopic = postAtts.isDeleted && details.can_recover; postAtts.canDeleteTopic = !postAtts.isDeleted && details.can_delete; postAtts.expandablePost = topic.expandable_first_post; + + // Show a "Flag to delete" message if not staff and you can't + // otherwise delete it. + postAtts.showFlagDelete = ( + !postAtts.canDelete && + postAtts.yours && + (currentUser && !currentUser.staff) + ); + } else { postAtts.canRecover = postAtts.isDeleted && postAtts.canRecover; postAtts.canDelete = diff --git a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 index dea4763d591..06fe905a472 100644 --- a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 @@ -307,7 +307,7 @@ registerButton("delete", attrs => { icon: "far-trash-alt", className: "delete" }; - } else if (!attrs.canDelete && attrs.firstPost && attrs.yours) { + } else if (attrs.showFlagDelete) { return { id: "delete_topic", action: "showDeleteTopicModal",