mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 11:46:18 +08:00
fe588cc7f8
* DEV: Fix the function prototype observers deprecation DEPRECATION: Function prototype extensions have been deprecated, please migrate from function(){}.observes('foo') to observer('foo', function() {}). [deprecation id: function-prototype-extensions.observes] See https://deprecations.emberjs.com/v3.x/#toc_function-prototype-extensions-observes for more details. * DEV: Fix the function prototype event listeners deprecation DEPRECATION: Function prototype extensions have been deprecated, please migrate from function(){}.on('foo') to on('foo', function() {}). [deprecation id: function-prototype-extensions.on] See https://deprecations.emberjs.com/v3.x/#toc_function-prototype-extensions-on for more details. * DEV: Simplify `default as` imports Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
import { alias } from "@ember/object/computed";
|
|
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
|
|
import discourseComputed, {
|
|
observes,
|
|
on
|
|
} from "discourse-common/utils/decorators";
|
|
import { buttonDetails } from "discourse/lib/notification-levels";
|
|
import { allLevels } from "discourse/lib/notification-levels";
|
|
|
|
export default DropdownSelectBoxComponent.extend({
|
|
classNames: "notifications-button",
|
|
nameProperty: "key",
|
|
fullWidthOnMobile: true,
|
|
content: allLevels,
|
|
castInteger: true,
|
|
autofilterable: false,
|
|
filterable: false,
|
|
rowComponent: "notifications-button/notifications-button-row",
|
|
allowInitialValueMutation: false,
|
|
i18nPrefix: "",
|
|
i18nPostfix: "",
|
|
|
|
@discourseComputed("iconForSelectedDetails")
|
|
headerIcon(iconForSelectedDetails) {
|
|
return iconForSelectedDetails;
|
|
},
|
|
|
|
@on("init")
|
|
@observes("i18nPostfix")
|
|
_setNotificationsButtonComponentOptions() {
|
|
this.rowComponentOptions.setProperties({
|
|
i18nPrefix: this.i18nPrefix,
|
|
i18nPostfix: this.i18nPostfix
|
|
});
|
|
},
|
|
|
|
iconForSelectedDetails: alias("selectedDetails.icon"),
|
|
|
|
computeHeaderContent() {
|
|
let content = this._super(...arguments);
|
|
content.name = I18n.t(
|
|
`${this.i18nPrefix}.${this.get("selectedDetails.key")}${this.get(
|
|
"i18nPostfix"
|
|
)}.title`
|
|
);
|
|
content.hasSelection = this.hasSelection;
|
|
return content;
|
|
},
|
|
|
|
@discourseComputed("computedValue")
|
|
selectedDetails(computedValue) {
|
|
return buttonDetails(computedValue);
|
|
}
|
|
});
|