From bc2c6b0918c10467d40aa690919917d9090c7b84 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 7 Nov 2016 12:11:52 -0500 Subject: [PATCH] FIX: Allow arrays of links for decorators --- .../javascripts/discourse/widgets/hamburger-menu.js.es6 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/widgets/hamburger-menu.js.es6 b/app/assets/javascripts/discourse/widgets/hamburger-menu.js.es6 index c944c40203e..f0e5319eb61 100644 --- a/app/assets/javascripts/discourse/widgets/hamburger-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/hamburger-menu.js.es6 @@ -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); }})); }