mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"),
|
||||
|
||||
|
||||
@@ -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"}}
|
||||
|
||||
@@ -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=""}}
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"}}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -524,6 +524,8 @@ en:
|
||||
word:
|
||||
too_many: "Too many words for that action"
|
||||
|
||||
uncategorized_category_name: "Uncategorized"
|
||||
|
||||
vip_category_name: "Lounge"
|
||||
vip_category_description: "A category exclusive to members with trust level 3 and higher."
|
||||
|
||||
@@ -590,7 +592,7 @@ en:
|
||||
permission_conflict: "Subcategory permissions cannot be less restrictive than parent's."
|
||||
disallowed_topic_tags: "This topic has tags not allowed by this category: '%{tags}'"
|
||||
cannot_delete:
|
||||
uncategorized: "Can't delete Uncategorized"
|
||||
uncategorized: "This category is special. It is intended as a holding area for topics that have no category; it cannot be deleted."
|
||||
has_subcategories: "Can't delete this category because it has sub-categories."
|
||||
topic_exists:
|
||||
one: "Can't delete this category because it has 1 topic. Oldest topic is %{topic_link}."
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class MigrateUncategorizedCategoryName < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
execute <<~SQL
|
||||
INSERT INTO translation_overrides (locale, translation_key, value, created_at, updated_at)
|
||||
SELECT '#{I18n.locale}', 'uncategorized_category_name', name, now(), now()
|
||||
FROM categories
|
||||
WHERE id = #{SiteSetting.uncategorized_category_id} AND LOWER(name) <> 'uncategorized';
|
||||
SQL
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user