Skip to content

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

DEV: Do not use string based actions in components (#31891)

Jarek Radoszd21aa14e2c2d
diff --git a/app/assets/javascripts/discourse/app/components/color-picker.gjs b/app/assets/javascripts/discourse/app/components/color-picker.gjs
index 7a37d7c8189..8f20d6766cb 100644
--- a/app/assets/javascripts/discourse/app/components/color-picker.gjs
+++ b/app/assets/javascripts/discourse/app/components/color-picker.gjs
@@ -28,7 +28,7 @@ export default class ColorPicker extends Component {
<ColorPickerChoice
@color={{c}}
@usedColors={{this.usedColors}}
- @selectColor={{action "selectColor"}}
+ @selectColor={{this.selectColor}}
@ariaLabel={{this.getColorLabel c}}
>
{{icon "check"}}
diff --git a/app/assets/javascripts/discourse/app/components/date-time-input-range.gjs b/app/assets/javascripts/discourse/app/components/date-time-input-range.gjs
index 8d9c4b4dc72..da0a0e0b802 100644
--- a/app/assets/javascripts/discourse/app/components/date-time-input-range.gjs
+++ b/app/assets/javascripts/discourse/app/components/date-time-input-range.gjs
@@ -1,5 +1,5 @@
import Component from "@ember/component";
-import { hash } from "@ember/helper";
+import { fn, hash } from "@ember/helper";
import { action } from "@ember/object";
import { classNames } from "@ember-decorators/component";
import DateTimeInput from "discourse/components/date-time-input";
@@ -51,7 +51,7 @@ export default class DateTimeInputRange extends Component {
<template>
<DateTimeInput
@date={{this.from}}
- @onChange={{action "onChangeRanges" (hash prop="from")}}
+ @onChange={{fn this.onChangeRanges (hash prop="from")}}
@showTime={{this.showFromTime}}
@placeholder={{i18n "dates.from_placeholder"}}
@timezone={{@timezone}}
@@ -61,7 +61,7 @@ export default class DateTimeInputRange extends Component {
<DateTimeInput
@date={{this.to}}
@relativeDate={{this.from}}
- @onChange={{action "onChangeRanges" (hash prop="to")}}
+ @onChange={{fn this.onChangeRanges (hash prop="to")}}
@timeFirst={{this.toTimeFirst}}
@showTime={{this.showToTime}}
@clearable={{this.clearable}}
diff --git a/app/assets/javascripts/discourse/app/components/date-time-input.gjs b/app/assets/javascripts/discourse/app/components/date-time-input.gjs
index 0d2c44d674e..5c340d6b5a2 100644
--- a/app/assets/javascripts/discourse/app/components/date-time-input.gjs
+++ b/app/assets/javascripts/discourse/app/components/date-time-input.gjs
@@ -83,7 +83,7 @@ export default class DateTimeInput extends Component {
@date={{this.date}}
@placeholder={{this.placeholder}}
@relativeDate={{this.relativeDate}}
- @onChange={{action "onChangeDate"}}
+ @onChange={{this.onChangeDate}}
@useGlobalPickerContainer={{this.useGlobalPickerContainer}}
/>
{{/unless}}
@@ -92,7 +92,7 @@ export default class DateTimeInput extends Component {
<TimeInput
@date={{this.date}}
@relativeDate={{this.relativeDate}}
- @onChange={{action "onChangeTime"}}
+ @onChange={{this.onChangeTime}}
/>
{{/if}}
@@ -101,7 +101,7 @@ export default class DateTimeInput extends Component {
@date={{this.date}}
@placeholder={{this.placeholder}}
@relativeDate={{this.relativeDate}}
- @onChange={{action "onChangeDate"}}
+ @onChange={{this.onChangeDate}}
@useGlobalPickerContainer={{this.useGlobalPickerContainer}}
/>
{{/if}}
diff --git a/app/assets/javascripts/discourse/app/components/edit-category-images.gjs b/app/assets/javascripts/discourse/app/components/edit-category-images.gjs
index ec739d79a87..24e693de459 100644
--- a/app/assets/javascripts/discourse/app/components/edit-category-images.gjs
+++ b/app/assets/javascripts/discourse/app/components/edit-category-images.gjs
@@ -90,8 +90,8 @@ export default class EditCategoryImages extends buildCategoryPanel("images") {
<label>{{i18n "category.logo"}}</label>
<UppyImageUploader
@imageUrl={{this.logoImageUrl}}
- @onUploadDone={{action "logoUploadDone"}}
- @onUploadDeleted={{action "logoUploadDeleted"}}
+ @onUploadDone={{this.logoUploadDone}}
+ @onUploadDeleted={{this.logoUploadDeleted}}
@type="category_logo"
@id="category-logo-uploader"
class="no-repeat contain-image"
@@ -105,8 +105,8 @@ export default class EditCategoryImages extends buildCategoryPanel("images") {
<label>{{i18n "category.logo_dark"}}</label>
<UppyImageUploader
@imageUrl={{this.logoImageDarkUrl}}
- @onUploadDone={{action "logoDarkUploadDone"}}
- @onUploadDeleted={{action "logoDarkUploadDeleted"}}
+ @onUploadDone={{this.logoDarkUploadDone}}
+ @onUploadDeleted={{this.logoDarkUploadDeleted}}
@type="category_logo_dark"
@id="category-dark-logo-uploader"
class="no-repeat contain-image"
@@ -120,8 +120,8 @@ export default class EditCategoryImages extends buildCategoryPanel("images") {
<label>{{i18n "category.background_image"}}</label>
<UppyImageUploader
@imageUrl={{this.backgroundImageUrl}}
- @onUploadDone={{action "backgroundUploadDone"}}
- @onUploadDeleted={{action "backgroundUploadDeleted"}}
+ @onUploadDone={{this.backgroundUploadDone}}
+ @onUploadDeleted={{this.backgroundUploadDeleted}}
@type="category_background"
@id="category-background-uploader"
/>
@@ -131,8 +131,8 @@ export default class EditCategoryImages extends buildCategoryPanel("images") {
<label>{{i18n "category.background_image_dark"}}</label>
<UppyImageUploader
@imageUrl={{this.backgroundDarkImageUrl}}
- @onUploadDone={{action "backgroundDarkUploadDone"}}
- @onUploadDeleted={{action "backgroundDarkUploadDeleted"}}
+ @onUploadDone={{this.backgroundDarkUploadDone}}
+ @onUploadDeleted={{this.backgroundDarkUploadDeleted}}
@type="category_background_dark"
@id="category-dark-background-uploader"
/>
diff --git a/app/assets/javascripts/discourse/app/components/group-card-contents.gjs b/app/assets/javascripts/discourse/app/components/group-card-contents.gjs
index 187dd66acbe..c6fd5501edf 100644
--- a/app/assets/javascripts/discourse/app/components/group-card-contents.gjs
+++ b/app/assets/javascripts/discourse/app/components/group-card-contents.gjs
@@ -193,7 +193,7 @@ export default class GroupCardContents extends CardContentsBase {
{{#if this.group.messageable}}
<li>
<DButton
- @action={{action "messageGroup"}}
+ @action={{this.messageGroup}}
@icon="envelope"
@label="groups.message"
class="btn-primary group-message-button inline"
diff --git a/app/assets/javascripts/discourse/app/components/group-membership-button.gjs b/app/assets/javascripts/discourse/app/components/group-membership-button.gjs
index 1afb39e6b1e..2db1eac4130 100644
--- a/app/assets/javascripts/discourse/app/components/group-membership-button.gjs
+++ b/app/assets/javascripts/discourse/app/components/group-membership-button.gjs
@@ -105,7 +105,7 @@ export default class GroupMembershipButton extends Component {
<template>
{{#if this.canJoinGroup}}
<DButton
- @action={{action "joinGroup"}}
+ @action={{this.joinGroup}}
@icon="user-plus"
@label="groups.join"
@disabled={{this.updatingMembership}}
@@ -113,7 +113,7 @@ export default class GroupMembershipButton extends Component {
/>
{{else if this.canLeaveGroup}}
<DButton
- @action={{action "leaveGroup"}}
+ @action={{this.leaveGroup}}
@icon="user-xmark"
@label="groups.leave"
@disabled={{this.updatingMembership}}
@@ -121,7 +121,7 @@ export default class GroupMembershipButton extends Component {
/>
{{else if this.canRequestMembership}}
<DButton
- @action={{action "showRequestMembershipForm"}}
+ @action={{this.showRequestMembershipForm}}
@disabled={{this.loading}}
@icon="user-plus"
@label="groups.request"
diff --git a/app/assets/javascripts/discourse/app/components/pick-files-button.gjs b/app/assets/javascripts/discourse/app/components/pick-files-button.gjs
index c20d48da7dc..b0209a985b9 100644
--- a/app/assets/javascripts/discourse/app/components/pick-files-button.gjs
+++ b/app/assets/javascripts/discourse/app/components/pick-files-button.gjs
@@ -127,7 +127,7 @@ export default class PickFilesButton extends Component {
<template>
{{#if this.showButton}}
<DButton
- @action={{action "openSystemFilePicker"}}
+ @action={{this.openSystemFilePicker}}
@label={{this.label}}
@icon={{this.icon}}
/>
diff --git a/app/assets/javascripts/discourse/app/components/signup-cta.gjs b/app/assets/javascripts/discourse/app/components/signup-cta.gjs
index 410066f37fb..eaf259ff648 100644
--- a/app/assets/javascripts/discourse/app/components/signup-cta.gjs
+++ b/app/assets/javascripts/discourse/app/components/signup-cta.gjs
@@ -50,7 +50,7 @@ export default class SignupCta extends Component {
class="btn-primary"
/>
<DButton
- @action={{action "hideForSession"}}
+ @action={{this.hideForSession}}
@label="signup_cta.hide_session"
class="no-icon"
/>
diff --git a/app/assets/javascripts/discourse/app/components/time-shortcut-picker.gjs b/app/assets/javascripts/discourse/app/components/time-shortcut-picker.gjs
index e1dad3daafc..54c937c8ff1 100644
--- a/app/assets/javascripts/discourse/app/components/time-shortcut-picker.gjs
+++ b/app/assets/javascripts/discourse/app/components/time-shortcut-picker.gjs
@@ -293,7 +293,7 @@ export default class TimeShortcutPicker extends Component {
<TapTile
@tileId={{option.id}}
@activeTile={{grid.activeTile}}
- @onChange={{action "selectShortcut"}}
+ @onChange={{this.selectShortcut}}
>
<div class="tap-tile-title">{{i18n option.label}}</div>
diff --git a/app/assets/javascripts/discourse/app/components/topic-entrance.gjs b/app/assets/javascripts/discourse/app/components/topic-entrance.gjs
index 75085e1c538..86f4bf484c2 100644
--- a/app/assets/javascripts/discourse/app/components/topic-entrance.gjs
+++ b/app/assets/javascripts/discourse/app/components/topic-entrance.gjs
@@ -205,7 +205,7 @@ export default class TopicEntrance extends Component {
<template>
<DButton
- @action={{action "enterTop"}}
+ @action={{this.enterTop}}
@translatedAriaLabel={{i18n
"topic_entrance.sr_jump_top_button"
date=this.topDate
@@ -218,7 +218,7 @@ export default class TopicEntrance extends Component {
</DButton>
<DButton
- @action={{action "enterBottom"}}
+ @action={{this.enterBottom}}
@translatedAriaLabel={{i18n
"topic_entrance.sr_jump_bottom_button"
date=this.bottomDate
diff --git a/app/assets/javascripts/discourse/app/components/user-card-contents.gjs b/app/assets/javascripts/discourse/app/components/user-card-contents.gjs
index 874fb4fc27f..8205e4ae5a5 100644
--- a/app/assets/javascripts/discourse/app/components/user-card-contents.gjs
+++ b/app/assets/javascripts/discourse/app/components/user-card-contents.gjs
@@ -507,7 +507,7 @@ export default class UserCardContents extends CardContentsBase {
{{#if this.hasUserFilters}}
<li>
<DButton
- @action={{action "cancelFilter"}}
+ @action={{this.cancelFilter}}
@icon="xmark"
@label="topic.filters.cancel"
/>