2019-11-09 00:32:20 +08:00
|
|
|
import { empty } from "@ember/object/computed";
|
2017-12-13 17:49:32 +08:00
|
|
|
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
|
2019-11-08 05:38:28 +08:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2017-12-13 17:49:32 +08:00
|
|
|
|
|
|
|
export default DropdownSelectBoxComponent.extend({
|
|
|
|
pluginApiIdentifiers: ["toolbar-popup-menu-options"],
|
|
|
|
classNames: ["toolbar-popup-menu-options"],
|
2019-11-09 00:32:20 +08:00
|
|
|
isHidden: empty("computedContent"),
|
2017-12-13 17:49:32 +08:00
|
|
|
showFullTitle: false,
|
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("title")
|
2017-12-13 17:49:32 +08:00
|
|
|
collectionHeader(title) {
|
2017-12-26 16:51:45 +08:00
|
|
|
return `<h3>${title}</h3>`;
|
2017-12-13 17:49:32 +08:00
|
|
|
},
|
|
|
|
|
2018-09-18 17:31:23 +08:00
|
|
|
autoHighlight() {},
|
2017-12-13 17:49:32 +08:00
|
|
|
|
|
|
|
computeContent(content) {
|
2018-06-15 23:03:24 +08:00
|
|
|
return content
|
|
|
|
.map(contentItem => {
|
|
|
|
if (contentItem.condition) {
|
|
|
|
return {
|
|
|
|
icon: contentItem.icon,
|
|
|
|
name: I18n.t(contentItem.label),
|
|
|
|
id: contentItem.action
|
|
|
|
};
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.filter(contentItem => contentItem);
|
2017-12-13 17:49:32 +08:00
|
|
|
},
|
|
|
|
|
2018-07-24 02:19:36 +08:00
|
|
|
// composer is triggering a focus on textarea, we avoid instantly closing
|
|
|
|
// popup menu by tweaking the focus out behavior
|
|
|
|
onFilterInputFocusout() {}
|
2017-12-13 17:49:32 +08:00
|
|
|
});
|