FIX: Allow arrays of links for decorators
This commit is contained in:
parent
aa80c8cbdd
commit
bc2c6b0918
|
@ -3,6 +3,8 @@ import { h } from 'virtual-dom';
|
|||
import DiscourseURL from 'discourse/lib/url';
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
|
||||
const flatten = array => [].concat.apply([], array);
|
||||
|
||||
createWidget('priority-faq-link', {
|
||||
tagName: 'a.faq-priority.widget-link',
|
||||
|
||||
|
@ -105,8 +107,7 @@ export default createWidget('hamburger-menu', {
|
|||
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));
|
||||
},
|
||||
|
||||
|
@ -165,7 +166,7 @@ export default createWidget('hamburger-menu', {
|
|||
|
||||
if (currentUser && currentUser.staff) {
|
||||
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);
|
||||
}}));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue