FIX: extra-nav-item outlet no longer adds a DIV to UL

This amends the extensibility on navigation bar so extra nav items are not
added to a DIV nested into the UL, instead the LIs are rendered as usual
This commit is contained in:
Sam 2017-03-06 15:00:03 -05:00
parent f9aae7af6a
commit 3227d79430
5 changed files with 19 additions and 9 deletions

View File

@ -1,11 +1,17 @@
import { default as computed, observes } from "ember-addons/ember-computed-decorators";
import DiscourseURL from 'discourse/lib/url';
import { renderedConnectorsFor } from 'discourse/lib/plugin-connectors';
export default Ember.Component.extend({
tagName: 'ul',
classNameBindings: [':nav', ':nav-pills'],
id: 'navigation-bar',
init() {
this._super();
this.set('connectors', renderedConnectorsFor("extra-nav-item", null, this));
},
@computed("filterMode", "navItems")
selectedNavItem(filterMode, navItems){
var item = navItems.find(i => i.get('filterMode').indexOf(filterMode) === 0);

View File

@ -29,7 +29,7 @@
The list of disabled plugins is returned via the `Site` singleton.
**/
import { connectorsFor } from 'discourse/lib/plugin-connectors';
import { renderedConnectorsFor } from 'discourse/lib/plugin-connectors';
export default Ember.Component.extend({
tagName: 'span',
@ -38,14 +38,9 @@ export default Ember.Component.extend({
init() {
this._super();
const name = this.get('name');
if (name) {
const args = this.get('args');
const connectors = connectorsFor(name).filter(con => {
return con.connectorClass.shouldRender(args, this);
});
this.set('connectors', connectors);
this.set('connectors', renderedConnectorsFor(name, args, this));
}
}
});

View File

@ -92,6 +92,13 @@ export function connectorsFor(outletName) {
return _connectorCache[outletName] || [];
}
export function renderedConnectorsFor(outletName, args, context) {
return connectorsFor(outletName).filter(con => {
return con.connectorClass.shouldRender(args, context);
});
}
export function rawConnectorsFor(outletName) {
if (!_rawConnectorCache) { buildRawConnectorCache(); }
return _rawConnectorCache[outletName] || [];

View File

@ -2,4 +2,6 @@
{{navigation-item content=navItem filterMode=filterMode}}
{{/each}}
{{custom-html name="extraNavItem" tagName="li"}}
{{plugin-outlet name="extra-nav-item" tagName="li"}}
{{#each connectors as |c|}}
{{plugin-connector connector=c class=c.classNames tagName="li" args=(hash category=category filterMode=filterMode)}}
{{/each}}

View File

@ -15,7 +15,7 @@
noSubcategories=noSubcategories
hideSubcategories=showingSubcategoryList}}
{{navigation-bar navItems=navItems filterMode=filterMode}}
{{navigation-bar navItems=navItems filterMode=filterMode category=category}}
{{#if currentUser}}
{{category-notifications-button category=category}}