mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 01:53:59 +08:00

This commit converts the current chat plugin UI into the new "show plugin" UI already followed by AI and Gamification. In the process, I also: * Made a dedicated /new route to create new webhooks * Converted the webhook form to FormKit * Made some fixes and improvements to the `AdminPluginConfigPage`, `AdminPageHeader`, and `AdminPageSubheader` generic components, so more plugins can adopt the UI guidelines too. This includes adding a header outlet so plugins can add action buttons to the plugin show page header. * Fixes the submit button loading state for FormKit (by Joffrey) --------- Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
34 lines
979 B
JavaScript
34 lines
979 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 DiscourseChatIncomingWebhooksNew extends DiscourseRoute {
|
|
@service adminPluginNavManager;
|
|
@service currentUser;
|
|
|
|
async model() {
|
|
if (!this.currentUser?.admin) {
|
|
return { model: null };
|
|
}
|
|
|
|
try {
|
|
const model = await ajax("/admin/plugins/chat/hooks/new.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);
|
|
}
|
|
}
|
|
}
|