A platform for community discussion. Free, open, simple.
Allow plugins to specify custom nav items on mobile
Sam9472821331ca
diff --git a/app/assets/javascripts/discourse/components/navigation-bar.js.es6 b/app/assets/javascripts/discourse/components/navigation-bar.js.es6index 2487a0d50de..bb80145167c 100644--- a/app/assets/javascripts/discourse/components/navigation-bar.js.es6+++ b/app/assets/javascripts/discourse/components/navigation-bar.js.es6@@ -16,6 +16,22 @@ export default Ember.Component.extend({selectedNavItem(filterMode, navItems) {if (filterMode.indexOf("top/") === 0) { filterMode = "top"; }var item = navItems.find(i => i.get('filterMode').indexOf(filterMode) === 0);+ if (!item) {+ let connectors = this.get('connectors');+ let category = this.get('category');+ if (connectors && category) {+ connectors.forEach(c => {+ if (c.connectorClass && typeof(c.connectorClass.path) === "function" && typeof(c.connectorClass.displayName === "function")) {+ let path = c.connectorClass.path(category);+ if (path.indexOf(filterMode) > 0) {+ item = {+ displayName: c.connectorClass.displayName()+ };+ }+ }+ });+ }+ }return item || navItems[0];},diff --git a/app/assets/javascripts/discourse/templates/mobile/components/navigation-bar.hbs b/app/assets/javascripts/discourse/templates/mobile/components/navigation-bar.hbsindex b510a920c7e..9d1ffb0932a 100644--- a/app/assets/javascripts/discourse/templates/mobile/components/navigation-bar.hbs+++ b/app/assets/javascripts/discourse/templates/mobile/components/navigation-bar.hbs@@ -9,5 +9,8 @@{{#each navItems as |navItem|}}{{navigation-item content=navItem filterMode=filterMode category=category}}{{/each}}+ {{#each connectors as |c|}}+ {{plugin-connector connector=c class=c.classNames tagName="li" args=(hash category=category filterMode=filterMode)}}+ {{/each}}</ul>{{/if}}