FEATURE: show modal when user without permissions tries to delete their own topic (#6086)
This commit is contained in:
parent
af1d1db3da
commit
fa38891a98
|
@ -0,0 +1,6 @@
|
|||
{{#d-modal-body}}
|
||||
<p>{{{i18n "post.controls.delete_topic_disallowed_modal"}}}</p>
|
||||
{{/d-modal-body}}
|
||||
<div class="modal-footer">
|
||||
{{d-button action="closeModal" class="btn-primary" label="close"}}
|
||||
</div>
|
|
@ -1,6 +1,7 @@
|
|||
import { applyDecorators, createWidget } from "discourse/widgets/widget";
|
||||
import { avatarAtts } from "discourse/widgets/actions-summary";
|
||||
import { h } from "virtual-dom";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
|
||||
const LIKE_ACTION = 2;
|
||||
|
||||
|
@ -281,6 +282,14 @@ registerButton("delete", attrs => {
|
|||
icon: "trash-o",
|
||||
className: "delete"
|
||||
};
|
||||
} else if (!attrs.canDelete && attrs.firstPost && attrs.yours) {
|
||||
return {
|
||||
id: "delete_topic",
|
||||
action: "showDeleteTopicModal",
|
||||
title: "post.controls.delete_topic_disallowed",
|
||||
icon: "trash-o",
|
||||
className: "delete"
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -467,6 +476,10 @@ export default createWidget("post-menu", {
|
|||
this.state.adminVisible = false;
|
||||
},
|
||||
|
||||
showDeleteTopicModal() {
|
||||
showModal("delete-topic-disallowed");
|
||||
},
|
||||
|
||||
showMoreActions() {
|
||||
this.state.collapsed = false;
|
||||
if (!this.state.likedUsers.length) {
|
||||
|
|
|
@ -2104,6 +2104,8 @@ en:
|
|||
lock_post_description: "prevent the poster from editing this post"
|
||||
unlock_post: "Unlock Post"
|
||||
unlock_post_description: "allow the poster to edit this post"
|
||||
delete_topic_disallowed_modal: "You don't have permission to delete this topic. If you really want it to be deleted, submit a flag for moderator attention together with reasoning."
|
||||
delete_topic_disallowed: "you don't have permission to delete this topic"
|
||||
|
||||
actions:
|
||||
flag: 'Flag'
|
||||
|
|
|
@ -298,6 +298,30 @@ widgetTest(`delete topic button - can't delete`, {
|
|||
}
|
||||
});
|
||||
|
||||
widgetTest(
|
||||
`delete topic button - can't delete when topic author without permission`,
|
||||
{
|
||||
template:
|
||||
'{{mount-widget widget="post" args=args deletePost="deletePost"}}',
|
||||
beforeEach() {
|
||||
this.set("args", {
|
||||
canDeleteTopic: false,
|
||||
yours: true,
|
||||
firstPost: true
|
||||
});
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(this.$("button.delete").length, 1, `button is displayed`);
|
||||
assert.equal(
|
||||
this.$("button.delete").attr("title"),
|
||||
I18n.t("post.controls.delete_topic_disallowed"),
|
||||
`shows the right button title for users without permissions`
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
widgetTest("recover topic button", {
|
||||
template:
|
||||
'{{mount-widget widget="post" args=args recoverPost="recoverPost"}}',
|
||||
|
|
Loading…
Reference in New Issue