mirror of
https://github.com/discourse/discourse.git
synced 2024-12-24 10:13:47 +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.
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
import Component from "@ember/component";
|
|
import { action } from "@ember/object";
|
|
import { equal } from "@ember/object/computed";
|
|
import { tagName } from "@ember-decorators/component";
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
import I18n from "discourse-i18n";
|
|
|
|
const CUSTOM_REASON_KEY = "custom";
|
|
|
|
@tagName("")
|
|
export default class AdminPenaltyReason extends Component {
|
|
selectedReason = CUSTOM_REASON_KEY;
|
|
customReason = "";
|
|
|
|
reasonKeys = [
|
|
"not_listening_to_staff",
|
|
"consuming_staff_time",
|
|
"combative",
|
|
"in_wrong_place",
|
|
"no_constructive_purpose",
|
|
CUSTOM_REASON_KEY,
|
|
];
|
|
|
|
@equal("selectedReason", CUSTOM_REASON_KEY) isCustomReason;
|
|
|
|
@discourseComputed("reasonKeys")
|
|
reasons(keys) {
|
|
return keys.map((key) => {
|
|
return { id: key, name: I18n.t(`admin.user.suspend_reasons.${key}`) };
|
|
});
|
|
}
|
|
|
|
@action
|
|
setSelectedReason(value) {
|
|
this.set("selectedReason", value);
|
|
this.setReason();
|
|
}
|
|
|
|
@action
|
|
setCustomReason(value) {
|
|
this.set("customReason", value);
|
|
this.setReason();
|
|
}
|
|
|
|
setReason() {
|
|
if (this.isCustomReason) {
|
|
this.set("reason", this.customReason);
|
|
} else {
|
|
this.set(
|
|
"reason",
|
|
I18n.t(`admin.user.suspend_reasons.${this.selectedReason}`)
|
|
);
|
|
}
|
|
}
|
|
}
|