UX: add stock suspension reasons to suspend dialog. (#10990)

This commit is contained in:
Vinoth Kannan
2020-11-11 01:01:28 +05:30
committed by GitHub
parent fec9d6e578
commit 67de0367ff
5 changed files with 74 additions and 5 deletions
@@ -1,4 +1,52 @@
import Component from "@ember/component";
import discourseComputed from "discourse-common/utils/decorators";
import I18n from "I18n";
import { equal } from "@ember/object/computed";
import { action } from "@ember/object";
const CUSTOM_REASON_KEY = "custom";
export default Component.extend({
tagName: "",
selectedReason: CUSTOM_REASON_KEY,
customReason: "",
reasonKeys: [
"not_listening_to_staff",
"consuming_staff_time",
"combatative",
"in_wrong_place",
"no_constructive_purpose",
CUSTOM_REASON_KEY,
],
isCustomReason: equal("selectedReason", CUSTOM_REASON_KEY),
@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}`)
);
}
},
});
@@ -8,10 +8,20 @@
{{/if}}
</div>
</label>
{{text-field
value=reason
<label>
{{i18n "admin.user.suspend_reason_title"}}
</label>
{{combo-box
content=reasons
value=selectedReason
class="suspend-reason"
placeholderKey="admin.user.suspend_reason_placeholder"}}
onChange=(action setSelectedReason)}}
{{#if isCustomReason}}
{{text-field
value=customReason
class="suspend-reason"
onChange=(action setCustomReason)}}
{{/if}}
</div>
<label>