2017-11-10 04:33:36 +08:00
|
|
|
import { iconHTML } from 'discourse-common/lib/icon-library';
|
|
|
|
import DropdownSelectBox from "select-box-kit/components/dropdown-select-box";
|
|
|
|
import computed from "ember-addons/ember-computed-decorators";
|
|
|
|
import { on } from "ember-addons/ember-computed-decorators";
|
|
|
|
|
|
|
|
export default DropdownSelectBox.extend({
|
|
|
|
headerText: "admin.flags.agree",
|
|
|
|
headerIcon: "thumbs-o-up",
|
|
|
|
classNames: ["agree-flag", "admin-agree-flag-dropdown"],
|
|
|
|
adminTools: Ember.inject.service(),
|
|
|
|
nameProperty: "label",
|
|
|
|
|
|
|
|
@on("didReceiveAttrs")
|
|
|
|
_setAdminAgreeDropdownOptions() {
|
2017-11-15 04:44:16 +08:00
|
|
|
this.get('headerComponentOptions').setProperties({
|
|
|
|
selectedName: `${I18n.t(this.get("headerText"))} ...`,
|
|
|
|
icon: iconHTML("thumbs-o-up")
|
|
|
|
});
|
2017-11-10 04:33:36 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
@computed("adminTools", "post.user")
|
|
|
|
spammerDetails(adminTools, user) {
|
|
|
|
return adminTools.spammerDetails(user);
|
|
|
|
},
|
|
|
|
|
|
|
|
canDeleteSpammer: Ember.computed.and("spammerDetails.canDelete", "post.flaggedForSpam"),
|
|
|
|
|
|
|
|
@computed("post", "canDeleteSpammer")
|
|
|
|
content(post, canDeleteSpammer) {
|
|
|
|
const content = [];
|
|
|
|
|
2017-11-15 04:44:16 +08:00
|
|
|
if (post.user_deleted) {
|
2017-11-10 04:33:36 +08:00
|
|
|
content.push({
|
|
|
|
icon: "eye",
|
|
|
|
id: "confirm-agree-restore",
|
|
|
|
action: () => this.send("perform", "restore"),
|
|
|
|
label: I18n.t("admin.flags.agree_flag_restore_post"),
|
2017-11-15 04:44:16 +08:00
|
|
|
description: I18n.t("admin.flags.agree_flag_restore_post_title")
|
2017-11-10 04:33:36 +08:00
|
|
|
});
|
|
|
|
} else {
|
2017-11-15 04:44:16 +08:00
|
|
|
if (!post.get("postHidden")) {
|
2017-11-10 04:33:36 +08:00
|
|
|
content.push({
|
|
|
|
icon: "eye-slash",
|
|
|
|
action: () => this.send("perform", "hide"),
|
|
|
|
id: "confirm-agree-hide",
|
2017-11-15 04:44:16 +08:00
|
|
|
label: I18n.t("admin.flags.agree_flag_hide_post"),
|
|
|
|
description: I18n.t("admin.flags.agree_flag_hide_post_title")
|
2017-11-10 04:33:36 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
content.push({
|
|
|
|
icon: "thumbs-o-up",
|
|
|
|
id: "confirm-agree-keep",
|
2017-11-15 04:44:16 +08:00
|
|
|
description: I18n.t('admin.flags.agree_flag_title'),
|
2017-11-10 04:33:36 +08:00
|
|
|
action: () => this.send("perform", "keep"),
|
|
|
|
label: I18n.t("admin.flags.agree_flag"),
|
|
|
|
});
|
|
|
|
|
|
|
|
if (canDeleteSpammer) {
|
|
|
|
content.push({
|
|
|
|
title: I18n.t("admin.flags.delete_spammer_title"),
|
|
|
|
icon: "exclamation-triangle",
|
|
|
|
id: "delete-spammer",
|
|
|
|
action: () => this.send("deleteSpammer"),
|
|
|
|
label: I18n.t("admin.flags.delete_spammer"),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return content;
|
|
|
|
},
|
|
|
|
|
|
|
|
selectValueFunction(value) {
|
|
|
|
Ember.get(this._contentForValue(value), "action")();
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
deleteSpammer() {
|
|
|
|
let spammerDetails = this.get("spammerDetails");
|
2017-11-11 04:55:48 +08:00
|
|
|
this.attrs.removeAfter(spammerDetails.deleteUser());
|
2017-11-10 04:33:36 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
perform(action) {
|
|
|
|
let flaggedPost = this.get("post");
|
2017-11-11 04:55:48 +08:00
|
|
|
this.attrs.removeAfter(flaggedPost.agreeFlags(action));
|
2017-11-10 04:33:36 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|