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
|
@ -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}}
|
||||
|
|
|
@ -1583,6 +1583,9 @@ en:
|
|||
move_to_inbox:
|
||||
title: 'Move to Inbox'
|
||||
help: 'Move message back to Inbox'
|
||||
edit_message:
|
||||
help: 'Edit first post of the message'
|
||||
title: 'Edit Message'
|
||||
list: 'Topics'
|
||||
new: 'new topic'
|
||||
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", {
|
||||
loggedIn: true,
|
||||
settings: {
|
||||
|
@ -199,3 +207,19 @@ QUnit.test("remove featured link", assert => {
|
|||
// 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[2], 5, "also selected 2nd post below post #3");
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue