FIX: Don't show the "Flag to delete" message to staff

If they can't delete, flagging should not either.
This commit is contained in:
Robin Ward 2019-05-30 13:31:40 -04:00
parent 7a21f78f8c
commit 7a9e85b1d7
2 changed files with 11 additions and 1 deletions

View File

@ -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 =

View File

@ -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",