mirror of
https://github.com/hanzoai/forum.git
synced 2026-09-30 21:51:19 +00:00
In this PR, we added functionality to hide the admin header for edit/new actions - https://github.com/discourse/discourse/pull/30175 To make it work properly, we have to rename `show` to `edit` which is also a more accurate name.
35 lines
982 B
JavaScript
35 lines
982 B
JavaScript
import EmberObject from "@ember/object";
|
|
import { service } from "@ember/service";
|
|
import { ajax } from "discourse/lib/ajax";
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
|
import ChatChannel from "discourse/plugins/chat/discourse/models/chat-channel";
|
|
|
|
export default class DiscourseChatIncomingWebhooksEdit extends DiscourseRoute {
|
|
@service currentUser;
|
|
|
|
async model(params) {
|
|
if (!this.currentUser?.admin) {
|
|
return { model: null };
|
|
}
|
|
|
|
try {
|
|
const model = await ajax(
|
|
`/admin/plugins/chat/hooks/${params.id}/edit.json`
|
|
);
|
|
|
|
model.webhook = EmberObject.create(model.webhook);
|
|
model.webhook.chat_channel = ChatChannel.create(
|
|
model.webhook.chat_channel
|
|
);
|
|
model.chat_channels = model.chat_channels.map((channel) =>
|
|
ChatChannel.create(channel)
|
|
);
|
|
|
|
return model;
|
|
} catch (err) {
|
|
popupAjaxError(err);
|
|
}
|
|
}
|
|
}
|