Skip to content

A platform for community discussion. Free, open, simple.

DEV: Remove final `{{action` uses and enable lint rule (#32348)

David Tayloracc11cc9aae3
diff --git a/.template-lintrc.cjs b/.template-lintrc.cjs
index f78c8dc4f3f..65497436d12 100644
--- a/.template-lintrc.cjs
+++ b/.template-lintrc.cjs
@@ -6,5 +6,6 @@ module.exports = {
...templateLint.rules,
"no-capital-arguments": false, // TODO: we extensively use `args` argument name
"require-button-type": false,
+ "no-action": true,
},
};
diff --git a/app/assets/javascripts/admin/addon/components/emoji-uploader.gjs b/app/assets/javascripts/admin/addon/components/emoji-uploader.gjs
index 1b7c28e47b6..d3bd0b5eda5 100644
--- a/app/assets/javascripts/admin/addon/components/emoji-uploader.gjs
+++ b/app/assets/javascripts/admin/addon/components/emoji-uploader.gjs
@@ -129,7 +129,7 @@ export default class EmojiUploader extends Component {
@id="emoji-group-selector"
@value={{this.group}}
@content={{this.newEmojiGroups}}
- @onChange={{action "createEmojiGroup"}}
+ @onChange={{this.createEmojiGroup}}
@valueProperty={{null}}
@nameProperty={{null}}
@options={{hash allowAny=true}}
diff --git a/app/assets/javascripts/admin/addon/components/modal/scrub-rejected-user.gjs b/app/assets/javascripts/admin/addon/components/modal/scrub-rejected-user.gjs
index 42d5aec7920..a1967f7cc97 100644
--- a/app/assets/javascripts/admin/addon/components/modal/scrub-rejected-user.gjs
+++ b/app/assets/javascripts/admin/addon/components/modal/scrub-rejected-user.gjs
@@ -1,11 +1,13 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
+import { fn } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { isEmpty } from "@ember/utils";
import DButton from "discourse/components/d-button";
import DModal from "discourse/components/d-modal";
import TextField from "discourse/components/text-field";
+import withEventValue from "discourse/helpers/with-event-value";
import { i18n } from "discourse-i18n";
export default class ScrubRejectedUserModal extends Component {
@@ -40,7 +42,7 @@ export default class ScrubRejectedUserModal extends Component {
class="scrub-reason"
id="scrub-reason"
@placeholderKey="review.user.scrub_record.reason_placeholder"
- {{on "input" (action (mut this.scrubReason) value="target.value")}}
+ {{on "input" (withEventValue (fn (mut this.scrubReason)))}}
/>
</:body>
<:footer>
diff --git a/app/assets/javascripts/discourse/app/components/calendar-date-time-input.gjs b/app/assets/javascripts/discourse/app/components/calendar-date-time-input.gjs
index 39370af410c..0b02aeec2ff 100644
--- a/app/assets/javascripts/discourse/app/components/calendar-date-time-input.gjs
+++ b/app/assets/javascripts/discourse/app/components/calendar-date-time-input.gjs
@@ -134,7 +134,7 @@ export default class CalendarDateTimeInput extends Component {
@type="time"
@value={{this._time}}
class="time-picker"
- {{on "input" (action this.onChangeTime)}}
+ {{on "input" this.onChangeTime}}
/>
</div>
</div>
diff --git a/app/assets/javascripts/discourse/app/components/d-editor.gjs b/app/assets/javascripts/discourse/app/components/d-editor.gjs
index f3530ffd2f9..624d1886131 100644
--- a/app/assets/javascripts/discourse/app/components/d-editor.gjs
+++ b/app/assets/javascripts/discourse/app/components/d-editor.gjs
@@ -732,7 +732,7 @@ export default class DEditor extends Component {
<ToolbarPopupMenuOptions
@content={{this.popupMenuOptions}}
@onChange={{this.onPopupMenuAction}}
- @onOpen={{action b.action b}}
+ @onOpen={{fn b.action b}}
@tabindex={{-1}}
@onKeydown={{this.rovingButtonBar}}
@options={{hash icon=b.icon focusAfterOnChange=false}}
@@ -740,7 +740,7 @@ export default class DEditor extends Component {
/>
{{else}}
<DButton
- @action={{fn (action b.action) b}}
+ @action={{fn b.action b}}
@translatedTitle={{b.title}}
@label={{b.label}}
@icon={{b.icon}}
diff --git a/app/assets/javascripts/discourse/app/components/discovery/filter-navigation.gjs b/app/assets/javascripts/discourse/app/components/discovery/filter-navigation.gjs
index d9980603b52..725e5ebad77 100644
--- a/app/assets/javascripts/discourse/app/components/discovery/filter-navigation.gjs
+++ b/app/assets/javascripts/discourse/app/components/discovery/filter-navigation.gjs
@@ -1,7 +1,7 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { Input } from "@ember/component";
-import { hash } from "@ember/helper";
+import { fn, hash } from "@ember/helper";
import { action } from "@ember/object";
import { service } from "@ember/service";
import { and } from "truth-helpers";
@@ -67,7 +67,7 @@ export default class DiscoveryFilterNavigation extends Component {
<Input
class="topic-query-filter__filter-term"
@value={{this.newQueryString}}
- @enter={{action @updateTopicsListQueryParams this.newQueryString}}
+ @enter={{fn @updateTopicsListQueryParams this.newQueryString}}
@type="text"
id="queryStringInput"
autocomplete="off"
diff --git a/app/assets/javascripts/discourse/app/components/login-buttons.gjs b/app/assets/javascripts/discourse/app/components/login-buttons.gjs
index 4bc8036d818..2e9d5553004 100644
--- a/app/assets/javascripts/discourse/app/components/login-buttons.gjs
+++ b/app/assets/javascripts/discourse/app/components/login-buttons.gjs
@@ -1,4 +1,5 @@
import Component from "@ember/component";
+import { fn } from "@ember/helper";
import { on } from "@ember/modifier";
import { classNameBindings } from "@ember-decorators/component";
import GoogleIcon from "discourse/components/google-icon";
@@ -47,7 +48,7 @@ export default class LoginButtons extends Component {
<button
type="button"
class="btn btn-social {{b.name}}"
- {{on "click" (action this.externalLogin b)}}
+ {{on "click" (fn this.externalLogin b)}}
aria-label={{b.screenReaderTitle}}
>
{{#if b.isGoogle}}
diff --git a/app/assets/javascripts/discourse/app/components/reviewable-item.gjs b/app/assets/javascripts/discourse/app/components/reviewable-item.gjs
index 9ce2e2d2713..c9f8721ddc3 100644
--- a/app/assets/javascripts/discourse/app/components/reviewable-item.gjs
+++ b/app/assets/javascripts/discourse/app/components/reviewable-item.gjs
@@ -601,8 +601,8 @@ export default class ReviewableItem extends Component {
@tagName=""
@value={{editableValue this.reviewable f.id}}
@tagCategoryId={{this.tagCategoryId}}
- @valueChanged={{action "valueChanged" f.id}}
- @categoryChanged={{action "categoryChanged"}}
+ @valueChanged={{fn this.valueChanged f.id}}
+ @categoryChanged={{this.categoryChanged}}
/>
{{/let}}
</div>
@@ -633,14 +633,14 @@ export default class ReviewableItem extends Component {
<DButton
@disabled={{this.disabled}}
@icon="check"
- @action={{action "saveEdit"}}
+ @action={{this.saveEdit}}
@label="review.save"
class="btn-primary reviewable-action save-edit"
/>
<DButton
@disabled={{this.disabled}}
@icon="xmark"
- @action={{action "cancelEdit"}}
+ @action={{this.cancelEdit}}
@label="review.cancel"
class="btn-danger reviewable-action cancel-edit"
/>
@@ -648,7 +648,7 @@ export default class ReviewableItem extends Component {
{{#each this.reviewable.bundled_actions as |bundle|}}
<ReviewableBundledAction
@bundle={{bundle}}
- @performAction={{action "perform"}}
+ @performAction={{this.perform}}
@reviewableUpdating={{this.disabled}}
/>
{{/each}}
@@ -657,7 +657,7 @@ export default class ReviewableItem extends Component {
<DButton
@disabled={{this.disabled}}
@icon="pencil"
- @action={{action "edit"}}
+ @action={{this.edit}}
@label="review.edit"
class="reviewable-action btn-default edit"
/>
diff --git a/app/assets/javascripts/discourse/app/components/topic-footer-buttons.gjs b/app/assets/javascripts/discourse/app/components/topic-footer-buttons.gjs
index c85a31069e9..e438ce4f016 100644
--- a/app/assets/javascripts/discourse/app/components/topic-footer-buttons.gjs
+++ b/app/assets/javascripts/discourse/app/components/topic-footer-buttons.gjs
@@ -24,6 +24,10 @@ import PinnedButton from "select-kit/components/pinned-button";
import TopicNotificationsButton from "select-kit/components/topic-notifications-button";
import DMenu from "float-kit/components/d-menu";
+function bind(fn, context) {
+ return fn.bind(context);
+}
+
@attributeBindings("role")
export default class TopicFooterButtons extends Component {
elementId = "topic-footer-buttons";
@@ -151,7 +155,7 @@ export default class TopicFooterButtons extends Component {
@id={{concat "topic-footer-dropdown-" actionable.id}}
@value={{actionable.value}}
@content={{actionable.content}}
- @onChange={{action actionable.action}}
+ @onChange={{bind actionable.action this}}
@options={{hash
icon=actionable.icon
none=actionable.noneItem
diff --git a/app/assets/javascripts/discourse/app/static/wizard/components/fields/checkboxes.gjs b/app/assets/javascripts/discourse/app/static/wizard/components/fields/checkboxes.gjs
index 111e984cd0a..bcbcf359557 100644
--- a/app/assets/javascripts/discourse/app/static/wizard/components/fields/checkboxes.gjs
+++ b/app/assets/javascripts/discourse/app/static/wizard/components/fields/checkboxes.gjs
@@ -41,7 +41,7 @@ export default class Checkboxes extends Component {
@type="checkbox"
class="wizard-container__checkbox"
@checked={{c.checked}}
- {{on "click" (action "changed")}}
+ {{on "click" this.changed}}
/>
{{#if c.icon}}
{{icon c.icon}}
diff --git a/app/assets/javascripts/select-kit/addon/components/mini-tag-chooser/selected-collection.gjs b/app/assets/javascripts/select-kit/addon/components/mini-tag-chooser/selected-collection.gjs
index 89e3a9424bc..35d021f4922 100644
--- a/app/assets/javascripts/select-kit/addon/components/mini-tag-chooser/selected-collection.gjs
+++ b/app/assets/javascripts/select-kit/addon/components/mini-tag-chooser/selected-collection.gjs
@@ -38,7 +38,7 @@ export default class SelectedCollection extends Component {
<DButton
@translatedTitle={{tag.value}}
@icon="xmark"
- @action={{fn (action this.selectKit.deselect) tag.value}}
+ @action={{fn this.selectKit.deselect tag.value}}
tabindex="0"
class={{tag.classNames}}
>
diff --git a/app/assets/javascripts/select-kit/addon/components/multi-select/multi-select-filter.gjs b/app/assets/javascripts/select-kit/addon/components/multi-select/multi-select-filter.gjs
index 05fc22434cd..26ff6fa76e8 100644
--- a/app/assets/javascripts/select-kit/addon/components/multi-select/multi-select-filter.gjs
+++ b/app/assets/javascripts/select-kit/addon/components/multi-select/multi-select-filter.gjs
@@ -54,10 +54,10 @@ export default class MultiSelectFilter extends SelectKitFilterComponent {
spellcheck={{false}}
@value={{readonly this.selectKit.filter}}
@type="search"
- {{on "paste" (action "onPaste")}}
- {{on "keydown" (action "onKeydown")}}
- {{on "keyup" (action "onKeyup")}}
- {{on "input" (action "onInput")}}
+ {{on "paste" this.onPaste}}
+ {{on "keydown" this.onKeydown}}
+ {{on "keyup" this.onKeyup}}
+ {{on "input" this.onInput}}
/>
{{#if this.selectKit.options.filterIcon}}
diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit.js b/app/assets/javascripts/select-kit/addon/components/select-kit.js
index 2240958205c..b0afcb22a97 100644
--- a/app/assets/javascripts/select-kit/addon/components/select-kit.js
+++ b/app/assets/javascripts/select-kit/addon/components/select-kit.js
@@ -635,9 +635,9 @@ export default class SelectKit extends Component.extend(UtilsMixin) {
}
}
- const action = get(this, actionName);
- if (boundaryAction && action) {
- boundaryAction = action.call(this, ...params);
+ const theAction = get(this, actionName);
+ if (boundaryAction && theAction) {
+ boundaryAction = theAction.call(this, ...params);
}
return boundaryAction;
diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-filter.gjs b/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-filter.gjs
index bbfb3672cda..76bee3df1d7 100644
--- a/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-filter.gjs
+++ b/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-filter.gjs
@@ -156,10 +156,10 @@ export default class SelectKitFilter extends Component.extend(UtilsMixin) {
spellcheck={{false}}
@value={{readonly this.selectKit.filter}}
@type="search"
- {{on "paste" (action "onPaste")}}
- {{on "keydown" (action "onKeydown")}}
- {{on "keyup" (action "onKeyup")}}
- {{on "input" (action "onInput")}}
+ {{on "paste" this.onPaste}}
+ {{on "keydown" this.onKeydown}}
+ {{on "keyup" this.onKeyup}}
+ {{on "input" this.onInput}}
/>
{{#if this.selectKit.options.filterIcon}}
diff --git a/plugins/automation/admin/assets/javascripts/admin/components/topic-trigger.gjs b/plugins/automation/admin/assets/javascripts/admin/components/topic-trigger.gjs
index 25b92bdbdb0..171b560611e 100644
--- a/plugins/automation/admin/assets/javascripts/admin/components/topic-trigger.gjs
+++ b/plugins/automation/admin/assets/javascripts/admin/components/topic-trigger.gjs
@@ -1,5 +1,7 @@
import { Input } from "@ember/component";
+import { fn } from "@ember/helper";
import { on } from "@ember/modifier";
+import withEventValue from "discourse/helpers/with-event-value";
import { i18n } from "discourse-i18n";
const TopicTrigger = <template>
@@ -11,10 +13,7 @@ const TopicTrigger = <template>
<div class="controls">
<Input
@value={{this.metadata.topic_id}}
- {{on
- "input"
- (action (mut this.metadata.topic_id) value="target.value")
- }}
+ {{on "input" (withEventValue (fn (mut this.metadata.topic_id)))}}
/>
</div>
</div>
diff --git a/plugins/automation/admin/assets/javascripts/discourse/templates/admin-plugins/show/automation/edit.gjs b/plugins/automation/admin/assets/javascripts/discourse/templates/admin-plugins/show/automation/edit.gjs
index 1e2c465f8fa..74adf894932 100644
--- a/plugins/automation/admin/assets/javascripts/discourse/templates/admin-plugins/show/automation/edit.gjs
+++ b/plugins/automation/admin/assets/javascripts/discourse/templates/admin-plugins/show/automation/edit.gjs
@@ -197,9 +197,9 @@ export default RouteTemplate(
@checked={{@controller.automationForm.enabled}}
{{on
"click"
- (action
- (mut @controller.automationForm.enabled)
- value="target.checked"
+ (withEventValue
+ (fn (mut @controller.automationForm.enabled))
+ "target.checked"
)
}}
/>