FEATURE: New 'Reviewable' model to make reviewable items generic

FEATURE: New ‘Reviewable’ model to make reviewable items generic

Includes support for flags, reviewable users and queued posts, with REST API backwards compatibility.

Co-Authored-By: romanrizzi romanalejandro@gmail.com Co-Authored-By: jjaffeux j.jaffeux@gmail.com

diff --git a/app/assets/javascripts/admin/adapters/flagged-post.js.es6 b/app/assets/javascripts/admin/adapters/flagged-post.js.es6
deleted file mode 100644
index dc44315..0000000
--- a/app/assets/javascripts/admin/adapters/flagged-post.js.es6
+++ /dev/null
@@ -1,38 +0,0 @@
-import RestAdapter from "discourse/adapters/rest";
-
-export default RestAdapter.extend({
-  pathFor(store, type, findArgs) {
-    let args = _.merge({ rest_api: true }, findArgs);
-    delete args.filter;
-    return `/admin/flags/${findArgs.filter}.json?${$.param(args)}`;
-  },
-
-  afterFindAll(results, helper) {
-    results.forEach(flag => {
-      let conversations = [];
-      flag.post_actions.forEach(pa => {
-        if (pa.conversation) {
-          let conversation = {
-            permalink: pa.permalink,
-            hasMore: pa.conversation.has_more,
-            response: {
-              excerpt: pa.conversation.response.excerpt,
-              user: helper.lookup("user", pa.conversation.response.user_id)
-            }
-          };
-
-          if (pa.conversation.reply) {
-            conversation.reply = {
-              excerpt: pa.conversation.reply.excerpt,
-              user: helper.lookup("user", pa.conversation.reply.user_id)
-            };
-          }
-          conversations.push(conversation);
-        }
-      });
-      flag.set("conversations", conversations);
-    });
-
-    return results;
-  }
-});
diff --git a/app/assets/javascripts/admin/components/flagged-post-response.js.es6 b/app/assets/javascripts/admin/components/flagged-post-response.js.es6
deleted file mode 100644
index e8dc2a2..0000000
--- a/app/assets/javascripts/admin/components/flagged-post-response.js.es6
+++ /dev/null
@@ -1,3 +0,0 @@
-export default Ember.Component.extend({
-  classNames: ["flagged-post-response"]
-});
diff --git a/app/assets/javascripts/admin/components/flagged-post-title.js.es6 b/app/assets/javascripts/admin/components/flagged-post-title.js.es6
deleted file mode 100644
index 4a6fa5d..0000000
--- a/app/assets/javascripts/admin/components/flagged-post-title.js.es6
+++ /dev/null
@@ -1,3 +0,0 @@
-export default Ember.Component.extend({
-  tagName: "h3"
-});
diff --git a/app/assets/javascripts/admin/components/flagged-post.js.es6 b/app/assets/javascripts/admin/components/flagged-post.js.es6
deleted file mode 100644
index 03edeba..0000000
--- a/app/assets/javascripts/admin/components/flagged-post.js.es6
+++ /dev/null
@@ -1,58 +0,0 @@
-import showModal from "discourse/lib/show-modal";
-import computed from "ember-addons/ember-computed-decorators";
-
-export default Ember.Component.extend({
-  adminTools: Ember.inject.service(),
-  expanded: false,
-  tagName: "div",
-  classNameBindings: [
-    ":flagged-post",
-    "flaggedPost.hidden:hidden-post",
-    "flaggedPost.deleted"
-  ],
-
-  canAct: Ember.computed.alias("actableFilter"),
-
-  @computed("filter")
-  actableFilter(filter) {
-    return filter === "active";
-  },
-
-  removeAfter(promise) {
-    return promise.then(() => this.attrs.removePost());
-  },
-
-  _spawnModal(name, model, modalClass) {
-    let controller = showModal(name, { model, admin: true, modalClass });
-    controller.removeAfter = p => this.removeAfter(p);
-  },
-
-  actions: {
-    removeAfter(promise) {
-      return this.removeAfter(promise);
-    },
-
-    disagree() {
-      this.removeAfter(this.get("flaggedPost").disagreeFlags());
-    },
-
-    defer() {
-      this.removeAfter(this.get("flaggedPost").deferFlags());
-    },
-
-    expand() {
-      this.get("flaggedPost")
-        .expandHidden()
-        .then(() => {
-          this.set("expanded", true);
-        });
-    },
-
-    showModerationHistory() {
-      this.get("adminTools").showModerationHistory({
-        filter: "post",
-        post_id: this.get("flaggedPost.id")
-      });
-    }
-  }
-});
diff --git a/app/assets/javascripts/admin/components/penalty-post-action.js.es6 b/app/assets/javascripts/admin/components/penalty-post-action.js.es6
index b4d82ab..d042e99 100644
--- a/app/assets/javascripts/admin/components/penalty-post-action.js.es6
+++ b/app/assets/javascripts/admin/components/penalty-post-action.js.es6
@@ -2,6 +2,7 @@ import computed from "ember-addons/ember-computed-decorators";
 
 const ACTIONS = ["delete", "edit", "none"];
 export default Ember.Component.extend({
+  postId: null,
   postAction: null,
   postEdit: null,
 
diff --git a/app/assets/javascripts/admin/components/user-flag-percentage.js.es6 b/app/assets/javascripts/admin/components/user-flag-percentage.js.es6
index cd6814c..cad6cd8 100644
--- a/app/assets/javascripts/admin/components/user-flag-percentage.js.es6
+++ b/app/assets/javascripts/admin/components/user-flag-percentage.js.es6
@@ -9,7 +9,7 @@ export default Ember.Component.extend({
   },
 
   // We do a little logic to choose which icon to display and which text
-  @computed("user.flags_agreed", "user.flags_disagreed", "user.flags_ignored")
+  @computed("agreed", "disagreed", "ignored")
   percentage(agreed, disagreed, ignored) {
     let total = agreed + disagreed + ignored;
     let result = { total };
diff --git a/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 b/app/assets/javascripts/admin/controllers/admin-user-index.js.es6
index 8c3b95b..3d5c252 100644
--- a/app/assets/javascripts/admin/controllers/admin-user-index.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-user-index.js.es6
@@ -13,7 +13,6 @@ export default Ember.Controller.extend(CanCheckEmails, {
   availableGroups: null,
   userTitleValue: null,
 
-  showApproval: setting("must_approve_users"),
   showBadges: setting("enable_badges"),
   hasLockedTrustLevel: Ember.computed.notEmpty(
     "model.manual_locked_trust_level"
@@ -215,9 +214,6 @@ export default Ember.Controller.extend(CanCheckEmails, {
         target_user: this.get("model.username")
       });
     },
-    showFlagsReceived() {
-      this.get("adminTools").showFlagsReceived(this.get("model"));
-    },
     showSuspendModal() {
       this.get("adminTools").showSuspendModal(this.get("model"));
     },
diff --git a/app/assets/javascripts/admin/controllers/admin-users-list-show.js.es6 b/app/assets/javascripts/admin/controllers/admin-users-list-show.js.es6
index 630c1c1..ed6f4d4 100644
--- a/app/assets/javascripts/admin/controllers/admin-users-list-show.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-users-list-show.js.es6
@@ -12,31 +12,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
   refreshing: false,
   listFilter: null,
   selectAll: false,
-
-  queryNew: Ember.computed.equal("query", "new"),
-  queryPending: Ember.computed.equal("query", "pending"),
-  queryHasApproval: Ember.computed.or("queryNew", "queryPending"),
-  showApproval: Ember.computed.and(
-    "siteSettings.must_approve_users",
-    "queryHasApproval"
-  ),
   searchHint: i18n("search_hint"),
-  hasSelection: Ember.computed.gt("selectedCount", 0),
-
-  selectedCount: function() {
-    var model = this.get("model");
-    if (!model || !model.length) return 0;
-    return model.filterBy("selected").length;
-  }.property("model.@each.selected"),
-
-  selectAllChanged: function() {
-    var val = this.get("selectAll");
-    this.get("model").forEach(function(user) {
-      if (user.get("can_approve")) {
-        user.set("selected", val);
-      }
-    });
-  }.observes("selectAll"),
 
   title: function() {
     return I18n.t("admin.users.titles." + this.get("query"));
@@ -60,34 +36,8 @@ export default Ember.Controller.extend(CanCheckEmails, {
   },
 
   actions: {
-    approveUsers: function() {
-      AdminUser.bulkApprove(this.get("model").filterBy("selected"));
-      this._refreshUsers();
-    },
-
-    rejectUsers: function() {
-      var maxPostAge = this.siteSettings.delete_user_max_post_age;
-      var controller = this;
-      AdminUser.bulkReject(this.get("model").filterBy("selected")).then(
-        function(result) {
-          var message = I18n.t("admin.users.reject_successful", {
-            count: result.success
-          });

[... diff too long, it was truncated ...]

GitHub sha: b58867b6

This commit has been mentioned on Discourse Meta. There might be relevant details there: