FIX: Allow arrays of links for decorators

This commit is contained in:
Robin Ward 2016-11-07 12:11:52 -05:00
parent aa80c8cbdd
commit bc2c6b0918
1 changed files with 4 additions and 3 deletions

View File

@ -3,6 +3,8 @@ import { h } from 'virtual-dom';
import DiscourseURL from 'discourse/lib/url'; import DiscourseURL from 'discourse/lib/url';
import { ajax } from 'discourse/lib/ajax'; import { ajax } from 'discourse/lib/ajax';
const flatten = array => [].concat.apply([], array);
createWidget('priority-faq-link', { createWidget('priority-faq-link', {
tagName: 'a.faq-priority.widget-link', tagName: 'a.faq-priority.widget-link',
@ -105,8 +107,7 @@ export default createWidget('hamburger-menu', {
links.push({ route: 'tags', label: 'tagging.tags' }); links.push({ route: 'tags', label: 'tagging.tags' });
} }
const extraLinks = applyDecorators(this, 'generalLinks', this.attrs, this.state); const extraLinks = flatten(applyDecorators(this, 'generalLinks', this.attrs, this.state));
return links.concat(extraLinks).map(l => this.attach('link', l)); return links.concat(extraLinks).map(l => this.attach('link', l));
}, },
@ -165,7 +166,7 @@ export default createWidget('hamburger-menu', {
if (currentUser && currentUser.staff) { if (currentUser && currentUser.staff) {
results.push(this.attach('menu-links', { contents: () => { results.push(this.attach('menu-links', { contents: () => {
const extraLinks = applyDecorators(this, 'admin-links', this.attrs, this.state) || []; const extraLinks = flatten(applyDecorators(this, 'admin-links', this.attrs, this.state));
return this.adminLinks().concat(extraLinks); return this.adminLinks().concat(extraLinks);
}})); }}));
} }