FEATURE: Category Reviewable by Group

FEATURE: Category Reviewable by Group

Allow a group to review content in a particular category.

diff --git a/app/assets/javascripts/discourse/components/edit-category-settings.js.es6 b/app/assets/javascripts/discourse/components/edit-category-settings.js.es6
index b8a63ee..1cc6a2d 100644
--- a/app/assets/javascripts/discourse/components/edit-category-settings.js.es6
+++ b/app/assets/javascripts/discourse/components/edit-category-settings.js.es6
@@ -2,6 +2,7 @@ import { setting } from "discourse/lib/computed";
 import { buildCategoryPanel } from "discourse/components/edit-category-panel";
 import computed from "ember-addons/ember-computed-decorators";
 import { searchPriorities } from "discourse/components/concerns/category_search_priorities";
+import Group from "discourse/models/group";
 
 const categorySortCriteria = [];
 export function addCategorySortCriteria(criteria) {
@@ -41,6 +42,10 @@ export default buildCategoryPanel("settings", {
     ];
   },
 
+  groupFinder(term) {
+    return Group.findAll({ term, ignore_automatic: true });
+  },
+
   @computed
   availableViews() {
     return [
diff --git a/app/assets/javascripts/discourse/models/category.js.es6 b/app/assets/javascripts/discourse/models/category.js.es6
index 9e0c047..ce8a3c5 100644
--- a/app/assets/javascripts/discourse/models/category.js.es6
+++ b/app/assets/javascripts/discourse/models/category.js.es6
@@ -131,7 +131,8 @@ const Category = RestModel.extend({
         navigate_to_first_post_after_read: this.get(
           "navigate_to_first_post_after_read"
         ),
-        search_priority: this.get("search_priority")
+        search_priority: this.get("search_priority"),
+        reviewable_by_group_name: this.get("reviewable_by_group_name")
       },
       type: id ? "PUT" : "POST"
     });
diff --git a/app/assets/javascripts/discourse/templates/components/edit-category-settings.hbs b/app/assets/javascripts/discourse/templates/components/edit-category-settings.hbs
index d2783f1..8c1f547 100644
--- a/app/assets/javascripts/discourse/templates/components/edit-category-settings.hbs
+++ b/app/assets/javascripts/discourse/templates/components/edit-category-settings.hbs
@@ -25,7 +25,7 @@
         {{i18n "category.num_featured_topics"}}
       {{/if}}
     </label>
-        {{text-field value=category.num_featured_topics id="category-number-featured-topics" type="number"}}
+    {{text-field value=category.num_featured_topics id="category-number-featured-topics" type="number"}}
   </section>
 
   <section class="field">
@@ -85,6 +85,19 @@
 
   <h3>{{i18n 'category.settings_sections.moderation'}}</h3>
 
+  {{#if siteSettings.enable_category_group_review}}
+    <section class="field">
+      <label for="reviewable-by-group">
+        {{i18n 'category.reviewable_by_group'}}
+      </label>
+      {{group-selector
+        groupFinder=groupFinder
+        single="true"
+        groupNames=category.reviewable_by_group_name
+        placeholderKey="category.review_group_name"}}
+    </section>
+  {{/if}}
+
   <section class="field">
     <label>
       {{input type="checkbox" checked=category.custom_fields.require_topic_approval}}
@@ -104,7 +117,7 @@
       <label for="topic-auto-close">
         {{i18n 'topic.auto_close.label'}}
       </label>
-            {{text-field value=category.auto_close_hours id="topic-auto-close" type="number"}}
+      {{text-field value=category.auto_close_hours id="topic-auto-close" type="number"}}
       <label>
         {{input type="checkbox" checked=category.auto_close_based_on_last_post}}
         {{i18n 'topic.auto_close.based_on_last_post'}}
@@ -117,7 +130,7 @@
       <label for="category-minimum-tags">
         {{i18n 'category.minimum_required_tags'}}
       </label>
-            {{text-field value=category.minimum_required_tags id="category-minimum-tags" type="number" min="0"}}
+      {{text-field value=category.minimum_required_tags id="category-minimum-tags" type="number" min="0"}}
     </section>
   {{/if}}
 
@@ -125,7 +138,7 @@
     <label for="category-number-daily-bump">
       {{i18n "category.num_auto_bump_daily"}}
     </label>
-        {{text-field value=category.custom_fields.num_auto_bump_daily id="category-number-daily-bump" type="number"}}
+    {{text-field value=category.custom_fields.num_auto_bump_daily id="category-number-daily-bump" type="number"}}
   </section>
 
 </section>
diff --git a/app/assets/javascripts/discourse/widgets/hamburger-menu.js.es6 b/app/assets/javascripts/discourse/widgets/hamburger-menu.js.es6
index 24032f8..ad610b7 100644
--- a/app/assets/javascripts/discourse/widgets/hamburger-menu.js.es6
+++ b/app/assets/javascripts/discourse/widgets/hamburger-menu.js.es6
@@ -57,14 +57,6 @@ export default createWidget("hamburger-menu", {
       }
     ];
 
-    links.push({
-      route: "review",
-      className: "review",
-      label: "review.title",
-      badgeCount: "reviewable_count",
-      badgeClass: "reviewables"
-    });
-
     if (currentUser.admin) {
       links.push({
         href: "/admin/site_settings/category/required",
@@ -120,6 +112,20 @@ export default createWidget("hamburger-menu", {
       });
     }
 
+    // Staff always see the review link. Non-staff will see it if there are items to review
+    if (
+      this.currentUser &&
+      (this.currentUser.staff || this.currentUser.reviewable_count)
+    ) {
+      links.push({
+        route: "review",
+        className: "review",
+        label: "review.title",
+        badgeCount: "reviewable_count",
+        badgeClass: "reviewables"
+      });
+    }
+
     links.push({
       route: "discovery.top",
       className: "top-topics-link",
diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb
index 4443583..7723b7f 100644
--- a/app/controllers/categories_controller.rb
+++ b/app/controllers/categories_controller.rb
@@ -269,37 +269,44 @@ class CategoriesController < ApplicationController
         params[:allowed_tag_groups] ||= []
       end
 
-      params.permit(*required_param_keys,
-                      :position,
-                      :email_in,
-                      :email_in_allow_strangers,
-                      :mailinglist_mirror,
-                      :suppress_from_latest,
-                      :all_topics_wiki,
-                      :parent_category_id,
-                      :auto_close_hours,
-                      :auto_close_based_on_last_post,
-                      :uploaded_logo_id,
-                      :uploaded_background_id,
-                      :slug,
-                      :allow_badges,
-                      :topic_template,
-                      :sort_order,
-                      :sort_ascending,
-                      :topic_featured_link_allowed,
-                      :show_subcategory_list,
-                      :num_featured_topics,
-                      :default_view,
-                      :subcategory_list_style,
-                      :default_top_period,
-                      :minimum_required_tags,
-                      :navigate_to_first_post_after_read,
-                      :search_priority,
-                      :allow_global_tags,
-                      custom_fields: [params[:custom_fields].try(:keys)],
-                      permissions: [*p.try(:keys)],
-                      allowed_tags: [],
-                      allowed_tag_groups: [])
+      result = params.permit(
+        *required_param_keys,
+        :position,
+        :email_in,
+        :email_in_allow_strangers,
+        :mailinglist_mirror,
+        :suppress_from_latest,
+        :all_topics_wiki,
+        :parent_category_id,
+        :auto_close_hours,
+        :auto_close_based_on_last_post,
+        :uploaded_logo_id,
+        :uploaded_background_id,
+        :slug,
+        :allow_badges,
+        :topic_template,
+        :sort_order,
+        :sort_ascending,
+        :topic_featured_link_allowed,
+        :show_subcategory_list,
+        :num_featured_topics,
+        :default_view,
+        :subcategory_list_style,
+        :default_top_period,
+        :minimum_required_tags,

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

GitHub sha: 404b35bd

1 Like

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