mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 17:11:07 +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:
@ -28,6 +28,11 @@ export default Ember.Component.extend({
|
|||||||
return !this.site.mobileView && this.currentUser && this.currentUser.get('canManageTopic');
|
return !this.site.mobileView && this.currentUser && this.currentUser.get('canManageTopic');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showEditOnFooter: Ember.computed.and(
|
||||||
|
'topic.isPrivateMessage',
|
||||||
|
'site.can_tag_pms'
|
||||||
|
),
|
||||||
|
|
||||||
@computed('topic.message_archived')
|
@computed('topic.message_archived')
|
||||||
archiveIcon: archived => archived ? '' : 'folder',
|
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
|
// Post related methods
|
||||||
replyToPost(post) {
|
replyToPost(post) {
|
||||||
const composerController = this.get('composer');
|
const composerController = this.get('composer');
|
||||||
|
@ -58,6 +58,14 @@
|
|||||||
action=toggleArchiveMessage}}
|
action=toggleArchiveMessage}}
|
||||||
{{/if}}
|
{{/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"
|
{{plugin-outlet name="topic-footer-main-buttons-before-create"
|
||||||
args=(hash topic=topic)
|
args=(hash topic=topic)
|
||||||
tagName=""
|
tagName=""
|
||||||
|
@ -251,6 +251,7 @@
|
|||||||
showFlagTopic=(action "topicRouteAction" "showFlagTopic")
|
showFlagTopic=(action "topicRouteAction" "showFlagTopic")
|
||||||
showInvite=(action "topicRouteAction" "showInvite")
|
showInvite=(action "topicRouteAction" "showInvite")
|
||||||
toggleArchiveMessage=(action "toggleArchiveMessage")
|
toggleArchiveMessage=(action "toggleArchiveMessage")
|
||||||
|
editFirstPost=(action "editFirstPost")
|
||||||
replyToPost=(action "replyToPost")
|
replyToPost=(action "replyToPost")
|
||||||
}}
|
}}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
@ -1583,6 +1583,9 @@ en:
|
|||||||
move_to_inbox:
|
move_to_inbox:
|
||||||
title: 'Move to Inbox'
|
title: 'Move to Inbox'
|
||||||
help: 'Move message back to Inbox'
|
help: 'Move message back to Inbox'
|
||||||
|
edit_message:
|
||||||
|
help: 'Edit first post of the message'
|
||||||
|
title: 'Edit Message'
|
||||||
list: 'Topics'
|
list: 'Topics'
|
||||||
new: 'new topic'
|
new: 'new topic'
|
||||||
unread: 'unread'
|
unread: 'unread'
|
||||||
|
@ -173,6 +173,14 @@ QUnit.test("Updating the topic title with emojis", assert => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test("does not show 'edit first post' button on topic/pm footer", assert => {
|
||||||
|
visit("/t/pm-for-testing/12");
|
||||||
|
|
||||||
|
andThen(() => {
|
||||||
|
assert.ok(!exists('.edit-message'), 'it does not show edit button');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
acceptance("Topic featured links", {
|
acceptance("Topic featured links", {
|
||||||
loggedIn: true,
|
loggedIn: true,
|
||||||
settings: {
|
settings: {
|
||||||
@ -199,3 +207,19 @@ QUnit.test("remove featured link", assert => {
|
|||||||
// assert.ok(!exists('.title-wrapper .topic-featured-link'), 'link is gone');
|
// assert.ok(!exists('.title-wrapper .topic-featured-link'), 'link is gone');
|
||||||
// });
|
// });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
acceptance("Personal message footer", {
|
||||||
|
loggedIn: true,
|
||||||
|
settings: {
|
||||||
|
allow_staff_to_tag_pms: true,
|
||||||
|
tagging_enabled: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.test("shows edit 'first post button' on PM footer", assert => {
|
||||||
|
visit("/t/pm-for-testing/12");
|
||||||
|
|
||||||
|
andThen(() => {
|
||||||
|
assert.ok(exists('.edit-message'), 'it shows the edit button');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -325,4 +325,3 @@ QUnit.test("selectBelow", function(assert) {
|
|||||||
assert.equal(selectedPostIds[1], 4, "also selected 1st post below post #3");
|
assert.equal(selectedPostIds[1], 4, "also selected 1st post below post #3");
|
||||||
assert.equal(selectedPostIds[2], 5, "also selected 2nd post below post #3");
|
assert.equal(selectedPostIds[2], 5, "also selected 2nd post below post #3");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user