From 932c169d46f02ad184e1e9cce0de9693b479a11a Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 8 Nov 2019 12:56:13 -0500 Subject: [PATCH] REFACTOR: Remove Discourse.NavItem constants --- .../javascripts/discourse/components/d-navigation.js.es6 | 3 ++- app/assets/javascripts/discourse/models/nav-item.js.es6 | 2 +- .../tilt/es6_module_transpiler_template.rb | 2 +- test/javascripts/models/nav-item-test.js.es6 | 9 +++------ 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/discourse/components/d-navigation.js.es6 b/app/assets/javascripts/discourse/components/d-navigation.js.es6 index 0fe007a1ed8..9ceea60eb4a 100644 --- a/app/assets/javascripts/discourse/components/d-navigation.js.es6 +++ b/app/assets/javascripts/discourse/components/d-navigation.js.es6 @@ -1,4 +1,5 @@ import discourseComputed from "discourse-common/utils/decorators"; +import NavItem from "discourse/models/nav-item"; import { inject as service } from "@ember/service"; import Component from "@ember/component"; @@ -47,7 +48,7 @@ export default Component.extend({ }, {}); } - return Discourse.NavItem.buildList(category, { + return NavItem.buildList(category, { filterMode, noSubcategories, persistedQueryParams: params diff --git a/app/assets/javascripts/discourse/models/nav-item.js.es6 b/app/assets/javascripts/discourse/models/nav-item.js.es6 index 0eff0051899..7ecebc4839f 100644 --- a/app/assets/javascripts/discourse/models/nav-item.js.es6 +++ b/app/assets/javascripts/discourse/models/nav-item.js.es6 @@ -185,7 +185,7 @@ NavItem.reopenClass({ } items = items - .map(i => Discourse.NavItem.fromText(i, args)) + .map(i => NavItem.fromText(i, args)) .filter( i => i !== null && !(category && i.get("name").indexOf("categor") === 0) ); diff --git a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb index fde7cfdd391..382417b8b4b 100644 --- a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb +++ b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb @@ -85,7 +85,7 @@ JS def whitelisted?(path) @@whitelisted ||= Set.new( - ["discourse/models/nav-item", + [ "discourse/routes/discourse", "discourse/models/category", "discourse/models/site", diff --git a/test/javascripts/models/nav-item-test.js.es6 b/test/javascripts/models/nav-item-test.js.es6 index 429b669d7ca..309ce31534f 100644 --- a/test/javascripts/models/nav-item-test.js.es6 +++ b/test/javascripts/models/nav-item-test.js.es6 @@ -1,7 +1,8 @@ import { run } from "@ember/runloop"; import createStore from "helpers/create-store"; +import NavItem from "discourse/models/nav-item"; -QUnit.module("Discourse.NavItem", { +QUnit.module("NavItem", { beforeEach() { run(function() { const asianCategory = Discourse.Category.create({ @@ -17,11 +18,7 @@ QUnit.test("href", assert => { assert.expect(4); function href(text, expected, label) { - assert.equal( - Discourse.NavItem.fromText(text, {}).get("href"), - expected, - label - ); + assert.equal(NavItem.fromText(text, {}).get("href"), expected, label); } href("latest", "/latest", "latest");