We refer to the channel name rather than title elsewhere (including the new channel modal), so we should be consistent. Title is an internal abstraction, since DM channels cannot have names (currently). Also change the name field on channel edit to a input type="text" rather than a textarea, since we don't want a huge input here.
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
import Controller from "@ember/controller";
|
|
import { action, computed } from "@ember/object";
|
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
|
import { inject as service } from "@ember/service";
|
|
export default class ChatChannelEditTitleController extends Controller.extend(
|
|
ModalFunctionality
|
|
) {
|
|
@service chatApi;
|
|
editedName = "";
|
|
|
|
@computed("model.title", "editedName")
|
|
get isSaveDisabled() {
|
|
return (
|
|
this.model.title === this.editedName ||
|
|
this.editedName?.length > this.siteSettings.max_topic_title_length
|
|
);
|
|
}
|
|
|
|
onShow() {
|
|
this.set("editedName", this.model.title || "");
|
|
}
|
|
|
|
onClose() {
|
|
this.set("editedName", "");
|
|
this.clearFlash();
|
|
}
|
|
|
|
@action
|
|
onSaveChatChannelName() {
|
|
return this.chatApi
|
|
.updateChannel(this.model.id, {
|
|
name: this.editedName,
|
|
})
|
|
.then((result) => {
|
|
this.model.set("title", result.channel.title);
|
|
this.send("closeModal");
|
|
})
|
|
.catch((event) => {
|
|
if (event.jqXHR?.responseJSON?.errors) {
|
|
this.flash(event.jqXHR.responseJSON.errors.join("\n"), "error");
|
|
}
|
|
});
|
|
}
|
|
|
|
@action
|
|
onChangeChatChannelName(title) {
|
|
this.clearFlash();
|
|
this.set("editedName", title);
|
|
}
|
|
}
|