FIX: Add deprecation for Discourse.NavItem in case themes are using it

FIX: Add deprecation for Discourse.NavItem in case themes are using it

diff --git a/app/assets/javascripts/discourse/models/nav-item.js.es6 b/app/assets/javascripts/discourse/models/nav-item.js.es6
index 4502757aee..c0cec002ae 100644
--- a/app/assets/javascripts/discourse/models/nav-item.js.es6
+++ b/app/assets/javascripts/discourse/models/nav-item.js.es6
@@ -3,6 +3,7 @@ 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")
@@ -255,3 +256,13 @@ export function addNavItem(item) {
   NavItem.extraNavItems.push(navItem);
   return navItem;
 }
+
+Object.defineProperty(Discourse, "NavItem", {
+  get() {
+    deprecated("Import the NavItem object instead of using Discourse.NavItem", {
+      since: "2.4.0",
+      dropFrom: "2.5.0"
+    });
+    return NavItem;
+  }
+});

GitHub sha: bd92fdeb

1 Like