DEV: Admin webhooks interface issues (#19360)

1. The events table had broken styling, making each row overflow
2. It had confusing routes: `/:id` for "edit" and `/:id/events` for "show" (now it's `/:id/edit` and `/:id` respectively)
3. There previously was an unused backend action (`#edit`) - now it is used (and `web_hooks/:id/events` route has been removed)
4. There was outdated/misplaced/duplicated CSS
5. And more
This commit is contained in:
Jarek Radosz
2022-12-13 01:53:08 +01:00
committed by GitHub
parent 4001e6f174
commit f9bdda84ca
23 changed files with 611 additions and 443 deletions

View File

@@ -123,7 +123,7 @@ export default function () {
{ path: "/web_hooks", resetNamespace: true },
function () {
this.route("show", { path: "/:web_hook_id" });
this.route("showEvents", { path: "/:web_hook_id/events" });
this.route("edit", { path: "/:web_hook_id/edit" });
}
);
});

View File

@@ -0,0 +1,28 @@
import DiscourseRoute from "discourse/routes/discourse";
export default DiscourseRoute.extend({
serialize(model) {
return { web_hook_id: model.id || "new" };
},
model(params) {
if (params.web_hook_id === "new") {
return this.store.createRecord("web-hook");
}
return this.store.find("web-hook", params.web_hook_id);
},
setupController(controller, model) {
this._super(...arguments);
if (model.get("isNew")) {
model.set(
"web_hook_event_types",
this.controllerFor("adminWebHooks").defaultEventTypes
);
}
controller.set("saved", false);
},
});

View File

@@ -1,21 +0,0 @@
import DiscourseRoute from "discourse/routes/discourse";
import { get } from "@ember/object";
export default DiscourseRoute.extend({
model(params) {
return this.store.findAll("web-hook-event", get(params, "web_hook_id"));
},
setupController(controller, model) {
controller.set("model", model);
controller.subscribe();
},
deactivate() {
this.controllerFor("adminWebHooks.showEvents").unsubscribe();
},
renderTemplate() {
this.render("admin/templates/web-hooks-show-events", { into: "adminApi" });
},
});

View File

@@ -1,30 +1,7 @@
import DiscourseRoute from "discourse/routes/discourse";
import { get } from "@ember/object";
export default DiscourseRoute.extend({
serialize(model) {
return { web_hook_id: model.get("id") || "new" };
},
model(params) {
if (params.web_hook_id === "new") {
return this.store.createRecord("web-hook");
}
return this.store.find("web-hook", get(params, "web_hook_id"));
},
setupController(controller, model) {
if (model.get("isNew")) {
model.set("web_hook_event_types", controller.get("defaultEventTypes"));
}
model.set("category_ids", model.get("category_ids"));
model.set("tag_names", model.get("tag_names"));
model.set("group_ids", model.get("group_ids"));
controller.setProperties({ model, saved: false });
},
renderTemplate() {
this.render("admin/templates/web-hooks-show", { into: "adminApi" });
return this.store.find("web-hook", params.web_hook_id);
},
});

View File

@@ -1,4 +1,5 @@
import Route from "@ember/routing/route";
export default Route.extend({
model() {
return this.store.findAll("web-hook");