2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

FEATURE: Staff members can lock posts

Locking a post prevents it from being edited. This is useful if the user
has posted something which has been edited out, and the staff members don't
want them to be able to edit it back in again.
This commit is contained in:
Robin Ward 2018-01-25 15:38:40 -05:00
parent 76317957ed
commit 6b04967e2f
19 changed files with 218 additions and 5 deletions

View file

@ -518,6 +518,14 @@ export default Ember.Controller.extend(BufferedContent, {
this.send('changeOwner');
},
lockPost(post) {
return post.updatePostField('locked', true);
},
unlockPost(post) {
return post.updatePostField('locked', false);
},
grantBadge(post) {
this.set("selectedPostIds", [post.id]);
this.send('showGrantBadgeModal');

View file

@ -77,6 +77,7 @@ export function transformBasicPost(post) {
cooked_hidden: !!post.cooked_hidden,
expandablePost: false,
replyCount: post.reply_count,
locked: post.locked
};
_additionalAttributes.forEach(a => postAtts[a] = post[a]);

View file

@ -175,6 +175,8 @@
rebakePost=(action "rebakePost")
changePostOwner=(action "changePostOwner")
grantBadge=(action "grantBadge")
lockPost=(action "lockPost")
unlockPost=(action "unlockPost")
unhidePost=(action "unhidePost")
replyToPost=(action "replyToPost")
toggleWiki=(action "toggleWiki")

View file

@ -73,6 +73,15 @@ export function buildManageButtons(attrs, currentUser) {
action: 'grantBadge',
className: 'grant-badge'
});
const action = attrs.locked ? "unlock" : "lock";
contents.push({
icon: action,
label: `post.controls.${action}_post`,
action: `${action}Post`,
title: `post.controls.${action}_post_description`,
className: `${action}-post`
});
}
if (attrs.canManage || attrs.canWiki) {

View file

@ -7,6 +7,7 @@ import { h } from 'virtual-dom';
import DiscourseURL from 'discourse/lib/url';
import { dateNode } from 'discourse/helpers/node';
import { translateSize, avatarUrl, formatUsername } from 'discourse/lib/utilities';
import hbs from 'discourse/widgets/hbs-compiler';
export function avatarImg(wanted, attrs) {
const size = translateSize(wanted);
@ -139,6 +140,12 @@ createWidget('post-avatar', {
}
});
createWidget('post-locked-indicator', {
tagName: 'div.post-info.post-locked',
template: hbs`{{d-icon "lock"}}`,
title: () => I18n.t("post.locked")
});
createWidget('post-email-indicator', {
tagName: 'div.post-info.via-email',
@ -207,6 +214,10 @@ createWidget('post-meta-data', {
result.push(this.attach('post-email-indicator', attrs));
}
if (attrs.locked) {
result.push(this.attach('post-locked-indicator', attrs));
}
if (attrs.version > 1 || attrs.wiki) {
result.push(this.attach('post-edits-indicator', attrs));
}

View file

@ -320,8 +320,11 @@ aside.quote {
}
.post-info {
&.via-email, &.whisper {
line-height: $line-height-medium;
}
&.via-email, &.whisper, &.post-locked {
margin-right: 5px;
.d-icon {
font-size: $font-0;