2019-03-27 05:41:50 -04:00
|
|
|
import DropdownSelectBox from "select-kit/components/dropdown-select-box";
|
2020-05-13 16:23:41 -04:00
|
|
|
import I18n from "I18n";
|
2020-02-03 08:22:14 -05:00
|
|
|
import { computed } from "@ember/object";
|
2019-03-27 05:41:50 -04:00
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
2019-03-29 06:14:53 -04:00
|
|
|
import showModal from "discourse/lib/show-modal";
|
2019-03-27 05:41:50 -04:00
|
|
|
|
|
|
|
export default DropdownSelectBox.extend({
|
|
|
|
classNames: ["user-notifications", "user-notifications-dropdown"],
|
2019-07-31 10:31:02 -04:00
|
|
|
|
2020-02-03 08:22:14 -05:00
|
|
|
selectKitOptions: {
|
|
|
|
headerIcon: "userNotificationicon",
|
|
|
|
},
|
|
|
|
|
|
|
|
userNotificationicon: computed("mainCollection.[]", "value", function () {
|
|
|
|
return (
|
|
|
|
this.mainCollection &&
|
|
|
|
this.mainCollection.find((row) => row.id === this.value).icon
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
|
|
|
|
content: computed(function () {
|
2019-03-27 05:41:50 -04:00
|
|
|
const content = [];
|
|
|
|
|
|
|
|
content.push({
|
|
|
|
icon: "user",
|
2019-03-29 06:14:53 -04:00
|
|
|
id: "changeToNormal",
|
|
|
|
description: I18n.t("user.user_notifications.normal_option_title"),
|
2020-02-03 08:22:14 -05:00
|
|
|
name: I18n.t("user.user_notifications.normal_option"),
|
2019-03-27 05:41:50 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
content.push({
|
|
|
|
icon: "times-circle",
|
2019-03-29 06:14:53 -04:00
|
|
|
id: "changeToMuted",
|
|
|
|
description: I18n.t("user.user_notifications.mute_option_title"),
|
2020-02-03 08:22:14 -05:00
|
|
|
name: I18n.t("user.user_notifications.mute_option"),
|
2019-03-27 05:41:50 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
if (this.get("user.can_ignore_user")) {
|
|
|
|
content.push({
|
2020-01-06 12:27:20 -05:00
|
|
|
icon: "far-eye-slash",
|
2019-03-29 06:14:53 -04:00
|
|
|
id: "changeToIgnored",
|
|
|
|
description: I18n.t("user.user_notifications.ignore_option_title"),
|
2020-02-03 08:22:14 -05:00
|
|
|
name: I18n.t("user.user_notifications.ignore_option"),
|
2019-03-27 05:41:50 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return content;
|
2020-02-03 08:22:14 -05:00
|
|
|
}),
|
2019-07-31 10:31:02 -04:00
|
|
|
|
2019-03-29 06:14:53 -04:00
|
|
|
changeToNormal() {
|
2019-07-31 10:31:02 -04:00
|
|
|
this.updateNotificationLevel("normal").catch(popupAjaxError);
|
2019-03-29 06:14:53 -04:00
|
|
|
},
|
|
|
|
changeToMuted() {
|
2019-07-31 10:31:02 -04:00
|
|
|
this.updateNotificationLevel("mute").catch(popupAjaxError);
|
2019-03-29 06:14:53 -04:00
|
|
|
},
|
|
|
|
changeToIgnored() {
|
2019-07-31 10:31:02 -04:00
|
|
|
showModal("ignore-duration", {
|
2019-05-27 04:15:39 -04:00
|
|
|
model: this.user,
|
2019-03-29 06:14:53 -04:00
|
|
|
});
|
2019-07-31 10:31:02 -04:00
|
|
|
},
|
|
|
|
|
2019-03-27 05:41:50 -04:00
|
|
|
actions: {
|
2020-02-03 08:22:14 -05:00
|
|
|
onChange(level) {
|
2019-03-29 06:14:53 -04:00
|
|
|
this[level]();
|
2020-02-03 08:22:14 -05:00
|
|
|
|
|
|
|
// hack but model.ignored/muted is not
|
|
|
|
// getting updated after updateNotificationLevel
|
|
|
|
this.set("value", level);
|
2019-03-27 05:41:50 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|