Files
forum/plugins/chat/admin/assets/javascripts/discourse/routes/admin-plugins-show-discourse-chat-incoming-webhooks-edit.js
Krzysztof KotlarekandGitHub f92bd4d255 UX: Hide admin header for edit/new webhook (#30194)
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.
2024-12-12 10:49:17 +11:00

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);
}
}
}