mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: show "edit message" button on message footer for staff
Show "Edit Message" button on personal message footer for staff if PM tagging is enabled.
This commit is contained in:
parent
410b90dde0
commit
4010d8d9f9
7 changed files with 58 additions and 1 deletions
|
@ -28,6 +28,11 @@ export default Ember.Component.extend({
|
|||
return !this.site.mobileView && this.currentUser && this.currentUser.get('canManageTopic');
|
||||
},
|
||||
|
||||
showEditOnFooter: Ember.computed.and(
|
||||
'topic.isPrivateMessage',
|
||||
'site.can_tag_pms'
|
||||
),
|
||||
|
||||
@computed('topic.message_archived')
|
||||
archiveIcon: archived => archived ? '' : 'folder',
|
||||
|
||||
|
|
|
@ -265,6 +265,23 @@ export default Ember.Controller.extend(BufferedContent, {
|
|||
}
|
||||
},
|
||||
|
||||
editFirstPost() {
|
||||
const postStream = this.get('model.postStream');
|
||||
let firstPost = postStream.get('posts.firstObject');
|
||||
|
||||
if (firstPost.get('post_number') !== 1) {
|
||||
const postId = postStream.findPostIdForPostNumber(1);
|
||||
// try loading from identity map first
|
||||
firstPost = postStream.findLoadedPost(postId);
|
||||
if (firstPost === undefined) {
|
||||
return this.get('model.postStream').loadPost(postId).then(post => {
|
||||
this.send("editPost", post);
|
||||
});
|
||||
}
|
||||
}
|
||||
this.send("editPost", firstPost);
|
||||
},
|
||||
|
||||
// Post related methods
|
||||
replyToPost(post) {
|
||||
const composerController = this.get('composer');
|
||||
|
|
|
@ -58,6 +58,14 @@
|
|||
action=toggleArchiveMessage}}
|
||||
{{/if}}
|
||||
|
||||
{{#if showEditOnFooter}}
|
||||
{{d-button class="edit-message"
|
||||
title="topic.edit_message.help"
|
||||
label="topic.edit_message.title"
|
||||
icon="pencil"
|
||||
action=editFirstPost}}
|
||||
{{/if}}
|
||||
|
||||
{{plugin-outlet name="topic-footer-main-buttons-before-create"
|
||||
args=(hash topic=topic)
|
||||
tagName=""
|
||||
|
|
|
@ -251,6 +251,7 @@
|
|||
showFlagTopic=(action "topicRouteAction" "showFlagTopic")
|
||||
showInvite=(action "topicRouteAction" "showInvite")
|
||||
toggleArchiveMessage=(action "toggleArchiveMessage")
|
||||
editFirstPost=(action "editFirstPost")
|
||||
replyToPost=(action "replyToPost")
|
||||
}}
|
||||
{{else}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue