Skip to content

A platform for community discussion. Free, open, simple.

DEV: Explicitly allow NavItem customization (#17061)

Jarek Radosz77632d2d36ad
diff --git a/app/assets/javascripts/discourse/app/models/nav-item.js b/app/assets/javascripts/discourse/app/models/nav-item.js
index 71f61e11d49..9b4cec0f764 100644
--- a/app/assets/javascripts/discourse/app/models/nav-item.js
+++ b/app/assets/javascripts/discourse/app/models/nav-item.js
@@ -17,27 +17,47 @@ import { reads } from "@ember/object/computed";
const NavItem = EmberObject.extend({
@discourseComputed("name")
- title(name) {
- return I18n.t("filters." + name.replace("/", ".") + ".help", {});
+ title: {
+ get(name) {
+ if (this._title) {
+ return this._title;
+ }
+
+ return I18n.t("filters." + name.replace("/", ".") + ".help", {});
+ },
+
+ set(value) {
+ this.set("_title", value);
+ },
},
@discourseComputed("name", "count")
- displayName(name, count) {
- count = count || 0;
-
- if (
- name === "latest" &&
- (!Site.currentProp("mobileView") || this.tagId !== undefined)
- ) {
- count = 0;
- }
+ displayName: {
+ get(name, count) {
+ if (this._displayName) {
+ return this._displayName;
+ }
- let extra = { count };
- const titleKey = count === 0 ? ".title" : ".title_with_count";
+ count = count || 0;
- return emojiUnescape(
- I18n.t(`filters.${name.replace("/", ".") + titleKey}`, extra)
- );
+ if (
+ name === "latest" &&
+ (!Site.currentProp("mobileView") || this.tagId !== undefined)
+ ) {
+ count = 0;
+ }
+
+ let extra = { count };
+ const titleKey = count === 0 ? ".title" : ".title_with_count";
+
+ return emojiUnescape(
+ I18n.t(`filters.${name.replace("/", ".") + titleKey}`, extra)
+ );
+ },
+
+ set(value) {
+ this.set("_displayName", value);
+ },
},
@discourseComputed("filterType", "category", "noSubcategories", "tagId")