mirror of
https://github.com/discourse/discourse.git
synced 2024-12-19 16:23:48 +08:00
c468110929
Before this change, webhooks could be only configured for specific groups like for example, all topic events. We would like to have more granular control like for example topic_created or topic_destroyed. Test are failing because plugins changed has to be merged as well: discourse/discourse-assign#498 discourse/discourse-solved#248 discourse/discourse-topic-voting#159
40 lines
842 B
JavaScript
40 lines
842 B
JavaScript
import Component from "@glimmer/component";
|
|
import I18n from "I18n";
|
|
|
|
export default class WebhookEventChooser extends Component {
|
|
get details() {
|
|
return I18n.t(
|
|
`admin.web_hooks.${this.args.group}_event.${this.args.type.name}`
|
|
);
|
|
}
|
|
|
|
get eventTypeExists() {
|
|
return this.args.eventTypes.any(
|
|
(event) => event.name === this.args.type.name
|
|
);
|
|
}
|
|
|
|
get enabled() {
|
|
return this.eventTypeExists;
|
|
}
|
|
|
|
set enabled(value) {
|
|
const eventTypes = this.args.eventTypes;
|
|
|
|
// add an association when not exists
|
|
if (value === this.eventTypeExists) {
|
|
return value;
|
|
}
|
|
|
|
if (value) {
|
|
eventTypes.addObject(this.args.type);
|
|
} else {
|
|
eventTypes.removeObjects(
|
|
eventTypes.filter((eventType) => eventType.name === this.args.type.name)
|
|
);
|
|
}
|
|
|
|
return value;
|
|
}
|
|
}
|