discourse/app/assets/javascripts/select-kit/addon/components/user-notifications-dropdown.js
Michael Brown d9a02d1336
Revert "Revert "Merge branch 'master' of https://github.com/discourse/discourse""
This reverts commit 20780a1eee.

* SECURITY: re-adds accidentally reverted commit:
  03d26cd6: ensure embed_url contains valid http(s) uri
* when the merge commit e62a85cf was reverted, git chose the 2660c2e2 parent to land on
  instead of the 03d26cd6 parent (which contains security fixes)
2020-05-23 00:56:13 -04:00

72 lines
1.9 KiB
JavaScript

import I18n from "I18n";
import DropdownSelectBox from "select-kit/components/dropdown-select-box";
import { popupAjaxError } from "discourse/lib/ajax-error";
import showModal from "discourse/lib/show-modal";
import { computed } from "@ember/object";
export default DropdownSelectBox.extend({
classNames: ["user-notifications", "user-notifications-dropdown"],
selectKitOptions: {
headerIcon: "userNotificationicon"
},
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("normal").catch(popupAjaxError);
},
changeToMuted() {
this.updateNotificationLevel("mute").catch(popupAjaxError);
},
changeToIgnored() {
showModal("ignore-duration", {
model: this.user
});
},
actions: {
onChange(level) {
this[level]();
// hack but model.ignored/muted is not
// getting updated after updateNotificationLevel
this.set("value", level);
}
}
});