DEV: Remove handling of category top menu items
Support for these kinds of navigation items was dropped in 88f52514
, but
the code for handling these menu items was never removed.
This commit is contained in:
parent
55bdd9e6a2
commit
e79cec9fc7
|
@ -1,25 +1,19 @@
|
|||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { toTitleCase } from "discourse/lib/formatter";
|
||||
import { emojiUnescape } from "discourse/lib/text";
|
||||
import Category from "discourse/models/category";
|
||||
import EmberObject from "@ember/object";
|
||||
import deprecated from "discourse-common/lib/deprecated";
|
||||
|
||||
const NavItem = EmberObject.extend({
|
||||
@discourseComputed("categoryName", "name")
|
||||
title(categoryName, name) {
|
||||
@discourseComputed("name")
|
||||
title(name) {
|
||||
const extra = {};
|
||||
|
||||
if (categoryName) {
|
||||
name = "category";
|
||||
extra.categoryName = categoryName;
|
||||
}
|
||||
|
||||
return I18n.t("filters." + name.replace("/", ".") + ".help", extra);
|
||||
},
|
||||
|
||||
@discourseComputed("categoryName", "name", "count")
|
||||
displayName(categoryName, name, count) {
|
||||
@discourseComputed("name", "count")
|
||||
displayName(name, count) {
|
||||
count = count || 0;
|
||||
|
||||
if (
|
||||
|
@ -32,35 +26,11 @@ const NavItem = EmberObject.extend({
|
|||
let extra = { count: count };
|
||||
const titleKey = count === 0 ? ".title" : ".title_with_count";
|
||||
|
||||
if (categoryName) {
|
||||
name = "category";
|
||||
extra.categoryName = toTitleCase(categoryName);
|
||||
}
|
||||
|
||||
return emojiUnescape(
|
||||
I18n.t(`filters.${name.replace("/", ".") + titleKey}`, extra)
|
||||
);
|
||||
},
|
||||
|
||||
@discourseComputed("name")
|
||||
categoryName(name) {
|
||||
const split = name.split("/");
|
||||
return split[0] === "category" ? split[1] : null;
|
||||
},
|
||||
|
||||
@discourseComputed("name")
|
||||
categorySlug(name) {
|
||||
const split = name.split("/");
|
||||
if (split[0] === "category" && split[1]) {
|
||||
const cat = Discourse.Site.current().categories.findBy(
|
||||
"nameLower",
|
||||
split[1].toLowerCase()
|
||||
);
|
||||
return cat ? Category.slugFor(cat) : null;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
@discourseComputed("filterMode")
|
||||
href(filterMode) {
|
||||
let customHref = null;
|
||||
|
@ -79,22 +49,18 @@ const NavItem = EmberObject.extend({
|
|||
return Discourse.getURL("/") + filterMode;
|
||||
},
|
||||
|
||||
@discourseComputed("name", "category", "categorySlug", "noSubcategories")
|
||||
filterMode(name, category, categorySlug, noSubcategories) {
|
||||
if (name.split("/")[0] === "category") {
|
||||
return "c/" + categorySlug;
|
||||
} else {
|
||||
let mode = "";
|
||||
if (category) {
|
||||
mode += "c/";
|
||||
mode += Category.slugFor(category);
|
||||
if (noSubcategories) {
|
||||
mode += "/none";
|
||||
}
|
||||
mode += "/l/";
|
||||
@discourseComputed("name", "category", "noSubcategories")
|
||||
filterMode(name, category, noSubcategories) {
|
||||
let mode = "";
|
||||
if (category) {
|
||||
mode += "c/";
|
||||
mode += Category.slugFor(category);
|
||||
if (noSubcategories) {
|
||||
mode += "/none";
|
||||
}
|
||||
return mode + name.replace(" ", "-");
|
||||
mode += "/l/";
|
||||
}
|
||||
return mode + name.replace(" ", "-");
|
||||
},
|
||||
|
||||
@discourseComputed("name", "category", "topicTrackingState.messageCount")
|
||||
|
|
|
@ -160,11 +160,11 @@ module Discourse
|
|||
end
|
||||
|
||||
def self.top_menu_items
|
||||
@top_menu_items ||= Discourse.filters + [:category, :categories, :top]
|
||||
@top_menu_items ||= Discourse.filters + [:categories, :top]
|
||||
end
|
||||
|
||||
def self.anonymous_top_menu_items
|
||||
@anonymous_top_menu_items ||= Discourse.anonymous_filters + [:category, :categories, :top]
|
||||
@anonymous_top_menu_items ||= Discourse.anonymous_filters + [:categories, :top]
|
||||
end
|
||||
|
||||
PIXEL_RATIOS ||= [1, 1.5, 2, 3]
|
||||
|
|
|
@ -41,7 +41,6 @@ export default {
|
|||
"starred",
|
||||
"read",
|
||||
"posted",
|
||||
"category",
|
||||
"categories",
|
||||
"top"
|
||||
],
|
||||
|
@ -49,7 +48,6 @@ export default {
|
|||
"latest",
|
||||
"top",
|
||||
"categories",
|
||||
"category",
|
||||
"categories",
|
||||
"top"
|
||||
],
|
||||
|
|
|
@ -38,11 +38,10 @@ PreloadStore.store("site", {
|
|||
"starred",
|
||||
"read",
|
||||
"posted",
|
||||
"category",
|
||||
"categories",
|
||||
"top"
|
||||
],
|
||||
anonymous_top_menu_items: ["latest", "category", "categories", "top"],
|
||||
anonymous_top_menu_items: ["latest", "categories", "top"],
|
||||
uncategorized_category_id: 17,
|
||||
categories: [
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ QUnit.module("NavItem", {
|
|||
});
|
||||
|
||||
QUnit.test("href", assert => {
|
||||
assert.expect(4);
|
||||
assert.expect(2);
|
||||
|
||||
function href(text, expected, label) {
|
||||
assert.equal(NavItem.fromText(text, {}).get("href"), expected, label);
|
||||
|
@ -24,8 +24,6 @@ QUnit.test("href", assert => {
|
|||
|
||||
href("latest", "/latest", "latest");
|
||||
href("categories", "/categories", "categories");
|
||||
href("category/bug", "/c/bug", "English category name");
|
||||
href("category/确实是这样", "/c/343434-category", "Chinese category name");
|
||||
});
|
||||
|
||||
QUnit.test("count", assert => {
|
||||
|
|
Loading…
Reference in New Issue