Skip to content

Commit

Permalink
FIX: handles boolean with popupMenuOption (discourse#7299)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jjaffeux authored Apr 1, 2019
1 parent a659666 commit 4b1b135
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/assets/javascripts/discourse/controllers/composer.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4b1b135

Please sign in to comment.