FEATURE: show modal when user without permissions tries to delete their own topic (#6086)

This commit is contained in:
Maja Komel
2018-07-18 23:31:37 +02:00
committed by Régis Hanol
parent af1d1db3da
commit fa38891a98
4 changed files with 45 additions and 0 deletions

View File

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

View File

@@ -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) {