mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 04:53:43 +08:00
c34f8b65cb
As of #23867 this is now a real package, so updating the imports to use the real package name, rather than relying on the alias. The name change in the package name is because `I18n` is not a valid name as NPM packages must be all lowercase. This commit also introduces an eslint rule to prevent importing from the old I18n path. For themes/plugins, the old 'i18n' name remains functional.
79 lines
2.1 KiB
JavaScript
79 lines
2.1 KiB
JavaScript
import { computed } from "@ember/object";
|
|
import { inject as service } from "@ember/service";
|
|
import IgnoreDurationModal from "discourse/components/modal/ignore-duration-with-username";
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
import I18n from "discourse-i18n";
|
|
import DropdownSelectBox from "select-kit/components/dropdown-select-box";
|
|
|
|
export default DropdownSelectBox.extend({
|
|
modal: service(),
|
|
|
|
classNames: ["user-notifications", "user-notifications-dropdown"],
|
|
|
|
selectKitOptions: {
|
|
headerIcon: "userNotificationIcon",
|
|
showCaret: true,
|
|
},
|
|
|
|
userNotificationIcon: computed("mainCollection.[]", "value", function () {
|
|
return (
|
|
this.mainCollection &&
|
|
this.mainCollection.find((row) => row.id === this.value).icon
|
|
);
|
|
}),
|
|
|
|
content: computed(function () {
|
|
const content = [];
|
|
|
|
content.push({
|
|
icon: "user",
|
|
id: "changeToNormal",
|
|
description: I18n.t("user.user_notifications.normal_option_title"),
|
|
name: I18n.t("user.user_notifications.normal_option"),
|
|
});
|
|
|
|
content.push({
|
|
icon: "times-circle",
|
|
id: "changeToMuted",
|
|
description: I18n.t("user.user_notifications.mute_option_title"),
|
|
name: I18n.t("user.user_notifications.mute_option"),
|
|
});
|
|
|
|
if (this.get("user.can_ignore_user")) {
|
|
content.push({
|
|
icon: "far-eye-slash",
|
|
id: "changeToIgnored",
|
|
description: I18n.t("user.user_notifications.ignore_option_title"),
|
|
name: I18n.t("user.user_notifications.ignore_option"),
|
|
});
|
|
}
|
|
|
|
return content;
|
|
}),
|
|
|
|
changeToNormal() {
|
|
this.updateNotificationLevel({ level: "normal" }).catch(popupAjaxError);
|
|
},
|
|
changeToMuted() {
|
|
this.updateNotificationLevel({ level: "mute" }).catch(popupAjaxError);
|
|
},
|
|
changeToIgnored() {
|
|
this.modal.show(IgnoreDurationModal, {
|
|
model: {
|
|
ignoredUsername: this.user.username,
|
|
enableSelection: false,
|
|
},
|
|
});
|
|
},
|
|
|
|
actions: {
|
|
onChange(level) {
|
|
this[level]();
|
|
|
|
// hack but model.ignored/muted is not
|
|
// getting updated after updateNotificationLevel
|
|
this.set("value", level);
|
|
},
|
|
},
|
|
});
|