discourse/app/assets/javascripts/admin/addon/controllers
Dan Gebhardt 03b7b7d1bc
DEV: Remove usage of {{action}} modifiers - Take 2 (#18476)
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.

This is a followup to #18333, which had to be reverted because it did not account for the default treatment of modifier keys by the {{action}} modifier.

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
* Introduce modKeysPressed utility
   Returns an array of modifier keys that are pressed during a given `MouseEvent` or `KeyboardEvent`.
* Don't interfere with click events on links with `href` values when modifier keys are pressed
2022-10-05 13:08:54 +01:00
..
admin-badges DEV: Remove usage of {{action}} modifiers - Take 2 (#18476) 2022-10-05 13:08:54 +01:00
modals DEV: Remove usage of {{action}} modifiers - Take 2 (#18476) 2022-10-05 13:08:54 +01: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
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
admin-backups.js
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
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
admin-customize-email-templates.js
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
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
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 - Take 2 (#18476) 2022-10-05 13:08:54 +01: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 - Take 2 (#18476) 2022-10-05 13:08:54 +01:00
admin-email-received.js
admin-email-rejected.js DEV: Remove usage of {{action}} modifiers - Take 2 (#18476) 2022-10-05 13:08:54 +01:00
admin-email-sent.js
admin-email-skipped.js
admin-embedding.js
admin-emojis.js DEV: Add A11Y-friendly dialog addon (#18028) 2022-08-29 13:59:57 -04:00
admin-logs-screened-emails.js
admin-logs-screened-ip-addresses.js DEV: Remove usage of {{action}} modifiers - Take 2 (#18476) 2022-10-05 13:08:54 +01:00
admin-logs-screened-urls.js
admin-logs-staff-action-logs.js DEV: Remove usage of {{action}} modifiers - Take 2 (#18476) 2022-10-05 13:08:54 +01: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
admin-search-logs-term.js
admin-site-settings-category.js
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
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 - Take 2 (#18476) 2022-10-05 13:08:54 +01: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