discourse/app/assets/javascripts/admin/addon/components/webhook-event-chooser.gjs
Sérgio Saquetim 480a24e754
DEV: Replace deprecated Ember's native array any with some (#35010)
Replaces deprecated usage of the Ember's native array extension `.any()`
function with `.some()` across several JavaScript files in the project.
This is a purely refactoring change intended to modernize the codebase
to follow current JavaScript standards.

**Main Changes:**

* Replaced .any() with .some() for array handling in 25 instances across
various files.
* Updated deprecation workflow to handle the any() and related
deprecations explicitly.
2025-09-30 15:49:13 -03:00

45 lines
1 KiB
Text
Vendored

import Component from "@glimmer/component";
import { Input } from "@ember/component";
import { i18n } from "discourse-i18n";
export default class WebhookEventChooser extends Component {
get details() {
return i18n(
`admin.web_hooks.${this.args.group}_event.${this.args.type.name}`
);
}
get eventTypeExists() {
return this.args.eventTypes.some(
(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;
}
if (value) {
eventTypes.addObject(this.args.type);
} else {
eventTypes.removeObjects(
eventTypes.filter((eventType) => eventType.name === this.args.type.name)
);
}
}
<template>
<label class="hook-event">
<Input @type="checkbox" @checked={{this.enabled}} name="event-choice" />
{{this.details}}
</label>
</template>
}