UX: Make Uncategorized category less confusing

UX: Make Uncategorized category less confusing

  • Adds warnings to the “Edit Category” dialog
  • Doesn’t hide the “Security” tab on the “Edit Category” dialog anymore. Instead, it shows an explanation why permissions can’t be changed.
  • Makes the category name translatable
  • Hides the category name from the edit dialog (it can be customized by overriding the translation)
  • Creates a translation override if the category has been renamed in the past
diff --git a/app/assets/javascripts/discourse/components/edit-category-general.js.es6 b/app/assets/javascripts/discourse/components/edit-category-general.js.es6
index 79f0d9c..aa4b442 100644
--- a/app/assets/javascripts/discourse/components/edit-category-general.js.es6
+++ b/app/assets/javascripts/discourse/components/edit-category-general.js.es6
@@ -9,6 +9,11 @@ export default buildCategoryPanel("general", {
   canSelectParentCategory: Ember.computed.not(
     "category.isUncategorizedCategory"
   ),
+  uncategorizedSiteSettingLink:
+    Discourse.BaseUri +
+    "/admin/site_settings/category/all_results?filter=allow_uncategorized_topics",
+  customizeTextContentLink:
+    Discourse.BaseUri + "/admin/customize/site_texts?q=uncategorized",
 
   // background colors are available as a pipe-separated string
   @computed
diff --git a/app/assets/javascripts/discourse/controllers/edit-category.js.es6 b/app/assets/javascripts/discourse/controllers/edit-category.js.es6
index cb0db1d..d474c9b 100644
--- a/app/assets/javascripts/discourse/controllers/edit-category.js.es6
+++ b/app/assets/javascripts/discourse/controllers/edit-category.js.es6
@@ -59,7 +59,6 @@ export default Ember.Controller.extend(ModalFunctionality, {
 
   saveLabel: function() {
     if (this.get("saving")) return "saving";
-    if (this.get("model.isUncategorizedCategory")) return "save";
     return this.get("model.id") ? "category.save" : "category.create";
   }.property("saving", "model.id"),
 
diff --git a/app/assets/javascripts/discourse/templates/components/category-name-fields.hbs b/app/assets/javascripts/discourse/templates/components/category-name-fields.hbs
index e0766f4..d6449d3 100644
--- a/app/assets/javascripts/discourse/templates/components/category-name-fields.hbs
+++ b/app/assets/javascripts/discourse/templates/components/category-name-fields.hbs
@@ -1,8 +1,10 @@
 <section class='field'>
-  <section class="field-item">
-    <label>{{i18n 'category.name'}}</label>
-    {{text-field value=category.name placeholderKey="category.name_placeholder" maxlength="50"}}
-  </section>
+  {{#unless category.isUncategorizedCategory}}
+    <section class="field-item">
+      <label>{{i18n 'category.name'}}</label>
+      {{text-field value=category.name placeholderKey="category.name_placeholder" maxlength="50"}}
+    </section>
+  {{/unless}}
   <section class="field-item">
     <label>{{i18n 'category.slug'}}</label>
     {{text-field value=category.slug placeholderKey="category.slug_placeholder" maxlength="255"}}
diff --git a/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs b/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs
index 1c01b53..03ae8ba 100644
--- a/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs
+++ b/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs
@@ -1,3 +1,10 @@
+{{#if category.isUncategorizedCategory}}
+  <p class="warning">
+    {{d-icon "warning"}}
+    {{{i18n 'category.uncategorized_general_warning' settingLink=uncategorizedSiteSettingLink customizeLink=customizeTextContentLink}}}
+  </p>
+{{/if}}
+
 <form>
   {{category-name-fields category=category tagName=""}}
 
diff --git a/app/assets/javascripts/discourse/templates/components/edit-category-security.hbs b/app/assets/javascripts/discourse/templates/components/edit-category-security.hbs
index ea241ad..a7efeec 100644
--- a/app/assets/javascripts/discourse/templates/components/edit-category-security.hbs
+++ b/app/assets/javascripts/discourse/templates/components/edit-category-security.hbs
@@ -1,19 +1,25 @@
 <section class='field'>
   {{#if category.is_special}}
-    <p class="warning">{{i18n 'category.special_warning'}}</p>
+    {{#if category.isUncategorizedCategory}}
+      <p class="warning">{{i18n 'category.uncategorized_security_warning'}}</p>
+    {{else}}
+      <p class="warning">{{i18n 'category.special_warning'}}</p>
+    {{/if}}
   {{/if}}
-  <ul class='permission-list'>
-    {{#each category.permissions as |p|}}
-      <li>
-        <span class="name"><span class="badge-group">{{p.group_name}}</span></span>
-        {{{i18n "category.can"}}}
-        <span class="permission">{{p.permission.description}}</span>
-        {{#if editingPermissions}}
-        <a class="remove-permission" href {{action "removePermission" p}}>{{d-icon "times-circle"}}</a>
-        {{/if}}
-      </li>
-    {{/each}}
-  </ul>
+  {{#unless category.isUncategorizedCategory}}
+    <ul class='permission-list'>
+      {{#each category.permissions as |p|}}
+        <li>
+          <span class="name"><span class="badge-group">{{p.group_name}}</span></span>
+          {{{i18n "category.can"}}}
+          <span class="permission">{{p.permission.description}}</span>
+          {{#if editingPermissions}}
+            <a class="remove-permission" href {{action "removePermission" p}}>{{d-icon "times-circle"}}</a>
+          {{/if}}
+        </li>
+      {{/each}}
+    </ul>
+  {{/unless}}
   {{#if editingPermissions}}
     {{#if category.availableGroups}}
       {{combo-box class="available-groups"
diff --git a/app/assets/javascripts/discourse/templates/modal/edit-category.hbs b/app/assets/javascripts/discourse/templates/modal/edit-category.hbs
index 675754b..d0029b0 100644
--- a/app/assets/javascripts/discourse/templates/modal/edit-category.hbs
+++ b/app/assets/javascripts/discourse/templates/modal/edit-category.hbs
@@ -1,9 +1,7 @@
 <div>
   <ul class="nav nav-pills">
     {{edit-category-tab panels=panels selectedTab=selectedTab tab="general"}}
-    {{#unless model.isUncategorizedCategory}}
-      {{edit-category-tab panels=panels selectedTab=selectedTab tab="security"}}
-    {{/unless}}
+    {{edit-category-tab panels=panels selectedTab=selectedTab tab="security"}}
     {{edit-category-tab panels=panels selectedTab=selectedTab tab="settings"}}
     {{edit-category-tab panels=panels selectedTab=selectedTab tab="images"}}
     {{edit-category-tab panels=panels selectedTab=selectedTab tab="topic-template"}}
diff --git a/app/serializers/basic_category_serializer.rb b/app/serializers/basic_category_serializer.rb
index 6be2df2..806f0cc 100644
--- a/app/serializers/basic_category_serializer.rb
+++ b/app/serializers/basic_category_serializer.rb
@@ -35,8 +35,12 @@ class BasicCategorySerializer < ApplicationSerializer
     parent_category_id
   end
 
+  def name
+    object.uncategorized? ? I18n.t('uncategorized_category_name', locale: SiteSetting.default_locale) : object.name
+  end
+
   def description
-    object.uncategorized? ? I18n.t('category.uncategorized_description') : object.description
+    object.uncategorized? ? I18n.t('category.uncategorized_description', locale: SiteSetting.default_locale) : object.description
   end
 
   def can_edit
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 4ae368e..b046ebd 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -2390,6 +2390,8 @@ en:
       already_used: "This color has been used by another category"
       security: "Security"
       special_warning: "Warning: This category is a pre-seeded category and the security settings cannot be edited. If you do not wish to use this category, delete it instead of repurposing it."
+      uncategorized_security_warning: "This category is special. It is intended as holding area for topics that have no category; it cannot have security settings."
+      uncategorized_general_warning: 'This category is special. It is used as the default category for new topics that do not have a category selected. If you want to prevent this behavior and force category selection, <a href="%{link}">please disable the setting here</a>. If you want to change the name or description, go to <a href="%{customizeLink}">Customize / Text Content</a>.'
       images: "Images"
       email_in: "Custom incoming email address:"
       email_in_allow_strangers: "Accept emails from anonymous users with no accounts"

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

GitHub sha: ccb48bef

1 Like

Why not use the Discourse.getURL method?

1 Like

Because I forgot about that method. :blush: I’ll change it right now. That makes it simpler.

1 Like

DEV: Use Discourse.getURL for creating URL