From 4b1b135ede5331ea6d5f901f3e735b74a3a1b7e9 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 1 Apr 2019 16:08:14 +0200 Subject: [PATCH] FIX: handles boolean with popupMenuOption (#7299) Handle the case of https://github.com/discourse/DiscoTOC doing this kind of setup: ``` return { action: "insertDtoc", icon: "align-left", label: themePrefix("insert_table_of_contents"), condition: !composerController.get("model.canCategorize") }; ``` In this case there's no function to call, it's already set. --- .../javascripts/discourse/controllers/composer.js.es6 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6 index b69ec6fdfec..a8897802c90 100644 --- a/app/assets/javascripts/discourse/controllers/composer.js.es6 +++ b/app/assets/javascripts/discourse/controllers/composer.js.es6 @@ -255,10 +255,12 @@ export default Ember.Controller.extend({ _setupPopupMenuOption(callback) { let option = callback(); - if (option.condition) { - option.condition = this.get(option.condition); - } else { + if (typeof option.condition === "undefined") { option.condition = true; + } else if (typeof option.condition === "boolean") { + // uses existing value + } else { + option.condition = this.get(option.condition); } return option;