2020-01-17 01:56:53 +08:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2019-11-05 22:10:23 +08:00
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
|
|
|
|
|
|
export default Ember.Controller.extend({
|
|
|
|
userModes: [
|
|
|
|
{ id: "all", name: I18n.t("admin.api.all_users") },
|
|
|
|
{ id: "single", name: I18n.t("admin.api.single_user") }
|
|
|
|
],
|
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("userMode")
|
2019-11-05 22:10:23 +08:00
|
|
|
showUserSelector(mode) {
|
|
|
|
return mode === "single";
|
|
|
|
},
|
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("model.description", "model.username", "userMode")
|
2019-11-05 22:10:23 +08:00
|
|
|
saveDisabled(description, username, userMode) {
|
|
|
|
if (Ember.isBlank(description)) return true;
|
|
|
|
if (userMode === "single" && Ember.isBlank(username)) return true;
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
changeUserMode(value) {
|
|
|
|
if (value === "all") {
|
|
|
|
this.model.set("username", null);
|
|
|
|
}
|
|
|
|
this.set("userMode", value);
|
|
|
|
},
|
|
|
|
|
|
|
|
save() {
|
2019-12-12 19:45:00 +08:00
|
|
|
this.model.save().catch(popupAjaxError);
|
|
|
|
},
|
|
|
|
|
|
|
|
continue() {
|
|
|
|
this.transitionToRoute("adminApiKeys.show", this.model.id);
|
2019-11-05 22:10:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|