2017-11-21 05:53:09 -05:00
|
|
|
import DropdownSelectBox from "select-kit/components/dropdown-select-box";
|
2017-11-09 15:33:36 -05:00
|
|
|
import computed from "ember-addons/ember-computed-decorators";
|
|
|
|
|
|
|
|
export default DropdownSelectBox.extend({
|
2017-11-21 05:53:09 -05:00
|
|
|
pluginApiIdentifiers: ["admin-agree-flag-dropdown"],
|
2017-11-09 15:33:36 -05:00
|
|
|
classNames: ["agree-flag", "admin-agree-flag-dropdown"],
|
|
|
|
adminTools: Ember.inject.service(),
|
|
|
|
nameProperty: "label",
|
2017-11-21 05:53:09 -05:00
|
|
|
allowInitialValueMutation: false,
|
|
|
|
headerIcon: "thumbs-o-up",
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2017-11-21 05:53:09 -05:00
|
|
|
computeHeaderContent() {
|
2018-03-22 06:29:55 -04:00
|
|
|
let content = this._super();
|
2017-11-21 05:53:09 -05:00
|
|
|
content.name = `${I18n.t("admin.flags.agree")}...`;
|
|
|
|
return content;
|
2017-11-09 15:33:36 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
@computed("adminTools", "post.user")
|
|
|
|
spammerDetails(adminTools, user) {
|
|
|
|
return adminTools.spammerDetails(user);
|
|
|
|
},
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
canDeleteSpammer: Ember.computed.and(
|
|
|
|
"spammerDetails.canDelete",
|
|
|
|
"post.flaggedForSpam"
|
|
|
|
),
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2017-11-21 05:53:09 -05:00
|
|
|
computeContent() {
|
2017-11-09 15:33:36 -05:00
|
|
|
const content = [];
|
2017-11-21 05:53:09 -05:00
|
|
|
const post = this.get("post");
|
|
|
|
const canDeleteSpammer = this.get("canDeleteSpammer");
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2017-11-14 15:44:16 -05:00
|
|
|
if (post.user_deleted) {
|
2017-11-09 15:33:36 -05:00
|
|
|
content.push({
|
|
|
|
icon: "eye",
|
|
|
|
id: "confirm-agree-restore",
|
|
|
|
action: () => this.send("perform", "restore"),
|
2018-06-15 11:03:24 -04:00
|
|
|
label: I18n.t("admin.flags.agree_flag_restore_post"),
|
|
|
|
description: I18n.t("admin.flags.agree_flag_restore_post_title")
|
2017-11-09 15:33:36 -05:00
|
|
|
});
|
|
|
|
} else {
|
2017-11-14 15:44:16 -05:00
|
|
|
if (!post.get("postHidden")) {
|
2017-11-09 15:33:36 -05:00
|
|
|
content.push({
|
|
|
|
icon: "eye-slash",
|
|
|
|
action: () => this.send("perform", "hide"),
|
|
|
|
id: "confirm-agree-hide",
|
2017-11-14 15:44:16 -05:00
|
|
|
label: I18n.t("admin.flags.agree_flag_hide_post"),
|
|
|
|
description: I18n.t("admin.flags.agree_flag_hide_post_title")
|
2017-11-09 15:33:36 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
content.push({
|
|
|
|
icon: "thumbs-o-up",
|
|
|
|
id: "confirm-agree-keep",
|
2018-06-15 11:03:24 -04:00
|
|
|
description: I18n.t("admin.flags.agree_flag_title"),
|
2017-11-09 15:33:36 -05:00
|
|
|
action: () => this.send("perform", "keep"),
|
2018-06-15 11:03:24 -04:00
|
|
|
label: I18n.t("admin.flags.agree_flag")
|
2017-11-09 15:33:36 -05:00
|
|
|
});
|
|
|
|
|
2018-01-30 16:31:29 -05:00
|
|
|
content.push({
|
2018-06-15 11:03:24 -04:00
|
|
|
icon: "ban",
|
|
|
|
id: "confirm-agree-suspend",
|
|
|
|
description: I18n.t("admin.flags.agree_flag_suspend_title"),
|
2018-01-30 16:31:29 -05:00
|
|
|
action: () => this.send("showSuspendModal"),
|
2018-06-15 11:03:24 -04:00
|
|
|
label: I18n.t("admin.flags.agree_flag_suspend")
|
2018-01-30 16:31:29 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
content.push({
|
2018-06-15 11:03:24 -04:00
|
|
|
icon: "microphone-slash",
|
|
|
|
id: "confirm-agree-silence",
|
|
|
|
description: I18n.t("admin.flags.agree_flag_silence_title"),
|
2018-01-30 16:31:29 -05:00
|
|
|
action: () => this.send("showSilenceModal"),
|
2018-06-15 11:03:24 -04:00
|
|
|
label: I18n.t("admin.flags.agree_flag_silence")
|
2018-01-30 16:31:29 -05:00
|
|
|
});
|
|
|
|
|
2017-11-09 15:33:36 -05:00
|
|
|
if (canDeleteSpammer) {
|
|
|
|
content.push({
|
2018-06-15 11:03:24 -04:00
|
|
|
title: I18n.t("admin.flags.delete_spammer_title"),
|
2017-11-09 15:33:36 -05:00
|
|
|
icon: "exclamation-triangle",
|
|
|
|
id: "delete-spammer",
|
|
|
|
action: () => this.send("deleteSpammer"),
|
2018-06-15 11:03:24 -04:00
|
|
|
label: I18n.t("admin.flags.delete_spammer")
|
2017-11-09 15:33:36 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return content;
|
|
|
|
},
|
|
|
|
|
2017-11-21 05:53:09 -05:00
|
|
|
mutateValue(value) {
|
2018-06-15 11:03:24 -04:00
|
|
|
const computedContentItem = this.get("computedContent").findBy(
|
|
|
|
"value",
|
|
|
|
value
|
|
|
|
);
|
2017-11-21 05:53:09 -05:00
|
|
|
Ember.get(computedContentItem, "originalContent.action")();
|
2017-11-09 15:33:36 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
deleteSpammer() {
|
|
|
|
let spammerDetails = this.get("spammerDetails");
|
2017-11-10 15:55:48 -05:00
|
|
|
this.attrs.removeAfter(spammerDetails.deleteUser());
|
2017-11-09 15:33:36 -05:00
|
|
|
},
|
|
|
|
|
2018-01-30 16:31:29 -05:00
|
|
|
showSuspendModal() {
|
2018-06-15 11:03:24 -04:00
|
|
|
let post = this.get("post");
|
|
|
|
let user = post.get("user");
|
|
|
|
this.get("adminTools").showSuspendModal(user, {
|
2018-01-30 16:31:29 -05:00
|
|
|
post,
|
|
|
|
before: () => {
|
2018-06-15 11:03:24 -04:00
|
|
|
return this.attrs.removeAfter(post.agreeFlags("suspended"));
|
2018-01-30 16:31:29 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
showSilenceModal() {
|
2018-06-15 11:03:24 -04:00
|
|
|
let post = this.get("post");
|
|
|
|
let user = post.get("user");
|
|
|
|
this.get("adminTools").showSilenceModal(user, {
|
2018-01-30 16:31:29 -05:00
|
|
|
post,
|
|
|
|
before: () => {
|
2018-06-15 11:03:24 -04:00
|
|
|
return this.attrs.removeAfter(post.agreeFlags("silenced"));
|
2018-01-30 16:31:29 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-11-09 15:33:36 -05:00
|
|
|
perform(action) {
|
|
|
|
let flaggedPost = this.get("post");
|
2017-11-10 15:55:48 -05:00
|
|
|
this.attrs.removeAfter(flaggedPost.agreeFlags(action));
|
2018-06-15 11:03:24 -04:00
|
|
|
}
|
2017-11-09 15:33:36 -05:00
|
|
|
}
|
|
|
|
});
|