discourse/app/assets/javascripts/admin/addon/controllers
Dan Gebhardt ba27ee1637
DEV: Remove usage of {{action}} modifiers (#18333)
This PR enables the [`no-action-modifiers`](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-action-modifiers.md) template lint rule and removes all usages of the `{{action}}` modifier in core.

In general, instances of `{{action "x"}}` have been replaced with `{{on "click" (action "x")}}`. 

In many cases, such as for `a` elements, we also need to prevent default event handling to avoid unwanted side effects. While the `{{action}}` modifier internally calls `event.preventDefault()`, we need to handle these cases more explicitly. For this purpose, this PR also adds the [ember-event-helpers](https://github.com/buschtoens/ember-event-helpers) dependency so we can use the `prevent-default` handler. For instance:

```
<a href {{on "click" (prevent-default (action "x"))}}>Do X</a>
```

Note that `action` has not in general been refactored away as a helper yet. In general, all event handlers should be methods on the corresponding component and referenced directly (e.g. `{{on "click" this.doSomething}}`). However, the `action` helper is used extensively throughout the codebase and often references methods in the `actions` hash on controllers or routes. Thus this refactor will also be extensive and probably deserves a separate PR.

Note: This work was done to complement #17767 by minimizing the potential impact of the `action` modifier override, which uses private API and arguably should be replaced with an AST transform.

Commits:
* Enable `no-action-modifiers` template lint rule
* Replace {{action "x"}} with {{on "click" (action "x")}}
* Remove unnecessary action helper usage
* Remove ctl+click tests for user-menu
   These tests now break in Chrome when used with addEventListener. As per the comment, they can probably be safely removed.
* Prevent default event handlers to avoid unwanted side effects
   Uses `event.preventDefault()` in event handlers to prevent default event handling. This had been done automatically by the `action` modifier, but is not always desirable or necessary.
* Restore UserCardContents#showUser action to avoid regression
   By keeping the `showUser` action, we can avoid a breaking change for plugins that rely upon it, while not interfering with the `showUser` argument that's been passed.
* Revert EditCategoryTab#selectTab -> EditCategoryTab#select
   Avoid potential breaking change in themes / plugins
* Restore GroupCardContents#showGroup action to avoid regression
   By keeping the `showGroup` action, we can avoid a breaking change for plugins that rely upon it, while not interfering with the `showGroup` argument that's been passed.
* Restore SecondFactorAddTotp#showSecondFactorKey action to avoid regression
   By keeping the `showSecondFactorKey` action, we can avoid a breaking change for plugins that rely upon it, while not interfering with the `showSecondFactorKey` property that's maintained on the controller.
* Refactor away from `actions` hash in ChooseMessage component
* Modernize EmojiPicker#onCategorySelection usage
* Modernize SearchResultEntry#logClick usage
* Modernize Discovery::Categories#showInserted usage
* Modernize Preferences::Account#resendConfirmationEmail usage
* Modernize MultiSelect::SelectedCategory#onSelectedNameClick usage
* Favor fn over action in SelectedChoice component
* Modernize WizardStep event handlers
* Favor fn over action usage in buttons
* Restore Login#forgotPassword action to avoid possible regression
2022-10-04 10:42:46 +02:00
..
admin-badges DEV: Remove usage of {{action}} modifiers (#18333) 2022-10-04 10:42:46 +02:00
modals DEV: Remove usage of {{action}} modifiers (#18333) 2022-10-04 10:42:46 +02:00
admin-api-keys-index.js FEATURE: Add pagination to API keys page (#14777) 2021-11-09 12:18:23 +02:00
admin-api-keys-new.js FEATURE: Add read-only scope to API keys (#14856) 2021-11-10 17:48:00 +02:00
admin-api-keys-show.js DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
admin-api-keys.js DEV: Modernize Ember Resolver (#17353) 2022-07-06 14:20:00 +01:00
admin-backups-index.js DEV: update yes/no confirmation dialogs (#18181) 2022-09-14 11:06:56 -04:00
admin-backups-logs.js DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
admin-backups.js DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
admin-badges.js DEV: Update /admin/badges to modern Ember patterns (#17672) 2022-08-03 10:12:17 +01:00
admin-customize-colors-show.js DEV: update yes/no confirmation dialogs (#18181) 2022-09-14 11:06:56 -04:00
admin-customize-colors.js DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
admin-customize-email-style-edit.js DEV: refactor bootbox alerts (#18292) 2022-09-27 14:47:13 -04:00
admin-customize-email-templates-edit.js DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
admin-customize-email-templates.js DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
admin-customize-robots-txt.js DEV: Fix typo in customize-robots-txt (#16599) 2022-05-02 22:54:05 +02:00
admin-customize-themes-edit.js DEV: Use method definition syntax consistently (#14915) 2021-11-13 14:01:55 +01:00
admin-customize-themes-show.js DEV: update yes/no confirmation dialogs (#18181) 2022-09-14 11:06:56 -04:00
admin-customize-themes.js FIX: Detect installed themes using URLs instead of names (#12201) 2021-02-25 00:10:17 +03:00
admin-dashboard-general.js DEV: Use import { inject as controller} Ember idiom (#13140) 2021-05-25 18:37:32 +02:00
admin-dashboard-moderation.js DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
admin-dashboard-reports.js DEV: Extensively use includes() (#17541) 2022-07-17 20:48:36 +02:00
admin-dashboard.js FEATURE: Scheduled group email credential problem check (#15396) 2022-01-04 10:14:33 +10:00
admin-email-advanced-test.js
admin-email-bounced.js DEV: Remove usage of {{action}} modifiers (#18333) 2022-10-04 10:42:46 +02:00
admin-email-index.js DEV: Add A11Y-friendly dialog addon (#18028) 2022-08-29 13:59:57 -04:00
admin-email-logs.js
admin-email-preview-digest.js DEV: Remove usage of {{action}} modifiers (#18333) 2022-10-04 10:42:46 +02:00
admin-email-received.js Revert "Revert "DEV: Wrap Ember.run.debounce. (#11352)"" (#11509) 2020-12-18 10:18:52 -03:00
admin-email-rejected.js DEV: Remove usage of {{action}} modifiers (#18333) 2022-10-04 10:42:46 +02:00
admin-email-sent.js Revert "Revert "DEV: Wrap Ember.run.debounce. (#11352)"" (#11509) 2020-12-18 10:18:52 -03:00
admin-email-skipped.js Revert "Revert "DEV: Wrap Ember.run.debounce. (#11352)"" (#11509) 2020-12-18 10:18:52 -03:00
admin-embedding.js DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
admin-emojis.js DEV: Add A11Y-friendly dialog addon (#18028) 2022-08-29 13:59:57 -04:00
admin-logs-screened-emails.js DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
admin-logs-screened-ip-addresses.js DEV: Remove usage of {{action}} modifiers (#18333) 2022-10-04 10:42:46 +02:00
admin-logs-screened-urls.js DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
admin-logs-staff-action-logs.js DEV: Remove usage of {{action}} modifiers (#18333) 2022-10-04 10:42:46 +02:00
admin-permalinks.js DEV: update yes/no confirmation dialogs (#18181) 2022-09-14 11:06:56 -04:00
admin-plugins.js DEV: refactors admin-plugins/admin-site-settings (#15244) 2021-12-09 13:47:56 +01:00
admin-reports-show.js FIX: ensure we dont collapse data multiple times (#13399) 2021-06-17 09:15:20 +02:00
admin-search-logs-index.js DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
admin-search-logs-term.js DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
admin-site-settings-category.js DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
admin-site-settings.js DEV: Replace deprecated String.prototype.substr() (#16233) 2022-04-01 17:35:17 +02:00
admin-site-text-edit.js DEV: Add A11Y-friendly dialog addon (#18028) 2022-08-29 13:59:57 -04:00
admin-site-text-index.js UX: Remove confusing fallback locale warning (#18096) 2022-08-26 01:22:04 +02:00
admin-user-badges.js DEV: update yes/no confirmation dialogs (#18181) 2022-09-14 11:06:56 -04:00
admin-user-fields.js DEV: prettier 2.2.1 (#11862) 2021-01-27 12:39:20 +01:00
admin-user-index.js FIX: Regression with admin user delete dialog buttons (#18179) 2022-09-05 09:31:17 +02:00
admin-user.js
admin-users-list-show.js FIX: Update user results page when no users found (#18363) 2022-09-26 16:37:56 +03:00
admin-watched-words-action.js DEV: update yes/no confirmation dialogs (#18181) 2022-09-14 11:06:56 -04:00
admin-watched-words.js DEV: Extensively use includes() (#17541) 2022-07-17 20:48:36 +02:00
admin-web-hooks-show-events.js DEV: Remove usage of {{action}} modifiers (#18333) 2022-10-04 10:42:46 +02:00
admin-web-hooks-show.js DEV: update yes/no confirmation dialogs (#18181) 2022-09-14 11:06:56 -04:00
admin-web-hooks.js DEV: update yes/no confirmation dialogs (#18181) 2022-09-14 11:06:56 -04:00
admin.js DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00