mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 18:35:28 +08:00
f9648de897
Co-Authored-By: Bianca Nenciu <nbianca@users.noreply.github.com> Co-Authored-By: David Taylor <david@taylorhq.com>
55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
|
|
import {
|
|
default as computed,
|
|
observes,
|
|
on
|
|
} from "ember-addons/ember-computed-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: "",
|
|
|
|
@computed("iconForSelectedDetails")
|
|
headerIcon(iconForSelectedDetails) {
|
|
return iconForSelectedDetails;
|
|
},
|
|
|
|
@on("init")
|
|
@observes("i18nPostfix")
|
|
_setNotificationsButtonComponentOptions() {
|
|
this.get("rowComponentOptions").setProperties({
|
|
i18nPrefix: this.get("i18nPrefix"),
|
|
i18nPostfix: this.get("i18nPostfix")
|
|
});
|
|
},
|
|
|
|
iconForSelectedDetails: Ember.computed.alias("selectedDetails.icon"),
|
|
|
|
computeHeaderContent() {
|
|
let content = this._super();
|
|
content.name = I18n.t(
|
|
`${this.get("i18nPrefix")}.${this.get("selectedDetails.key")}${this.get(
|
|
"i18nPostfix"
|
|
)}.title`
|
|
);
|
|
content.hasSelection = this.get("hasSelection");
|
|
return content;
|
|
},
|
|
|
|
@computed("computedValue")
|
|
selectedDetails(computedValue) {
|
|
return buttonDetails(computedValue);
|
|
}
|
|
});
|