mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:06:26 +08:00
FIX: Selecting categories for new admin webhooks (#26746)
This commit is contained in:
parent
0f2067b363
commit
c77d109362
|
@ -11,11 +11,15 @@ class WebHookExtras {
|
|||
@tracked categories;
|
||||
|
||||
constructor(args) {
|
||||
this.categories = args.categories;
|
||||
this.content_types = args.content_types;
|
||||
this.default_event_types = args.default_event_types;
|
||||
this.delivery_statuses = args.delivery_statuses;
|
||||
this.grouped_event_types = args.grouped_event_types;
|
||||
this.categories = args.categories || [];
|
||||
this.content_types = args.content_types || [];
|
||||
this.default_event_types = args.default_event_types || [];
|
||||
this.delivery_statuses = args.delivery_statuses || [];
|
||||
this.grouped_event_types = args.grouped_event_types || [];
|
||||
}
|
||||
|
||||
addCategories(categories) {
|
||||
this.categories = this.categories.concat(categories).uniqBy((c) => c.id);
|
||||
}
|
||||
|
||||
get categoriesById() {
|
||||
|
@ -56,6 +60,9 @@ export default class WebHook extends RestModel {
|
|||
}
|
||||
|
||||
set categories(value) {
|
||||
this.extras ||= new WebHookExtras({});
|
||||
this.extras.addCategories(value);
|
||||
|
||||
this.set(
|
||||
"category_ids",
|
||||
value.map((c) => c.id)
|
||||
|
|
|
@ -5,6 +5,7 @@ import pretender, {
|
|||
response,
|
||||
} from "discourse/tests/helpers/create-pretender";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
|
||||
acceptance("Admin - Webhooks", function (needs) {
|
||||
needs.user();
|
||||
|
@ -66,8 +67,12 @@ acceptance("Admin - Webhooks", function (needs) {
|
|||
await click(".admin-webhooks__new-button");
|
||||
|
||||
await fillIn(`[name="payload-url"`, "https://example.com/webhook");
|
||||
await click(".admin-webhooks__save-button");
|
||||
|
||||
const categorySelector = selectKit(".category-selector");
|
||||
await categorySelector.expand();
|
||||
categorySelector.selectRowByName("support");
|
||||
|
||||
await click(".admin-webhooks__save-button");
|
||||
assert.strictEqual(currentURL(), "/admin/api/web_hooks/1");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user