discourse/lib/tasks
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
..
add_topic_to_quotes.rake
admin.rake DEV: Use strings for :user_email job type argument 2022-02-04 18:28:18 +00:00
annotate.rake DEV: Add `annotate` rake tasks, and enforce via GitHub actions 2021-07-06 10:11:06 +01:00
api.rake
assets.rake FIX: Add wizard.js to ember-cli assets (#17153) 2022-06-20 17:18:35 +02:00
auto_annotate_models.rake DEV: Allow annotations to work in symlinked plugins, add binstub (#13635) 2021-07-05 15:43:10 +01:00
autospec.rake DEV: Add API docs for uploads and API doc watcher (#15387) 2021-12-23 08:40:15 +10:00
avatars.rake
backfill.thor
categories.rake FIX: rake categories:move_topics shouldn't move category description topic (#14797) 2021-11-03 11:27:51 +08:00
cdn.rake DEV: Fix rubocop issues (#14715) 2021-10-27 11:39:28 +03:00
db.rake Revert "DEV: Improve multisite db scripts in dev (#17337)" (#17801) 2022-08-04 16:15:06 -05:00
destroy.rake
dev.rake DEV: move `discourse_dev` gem to the core. (#13360) 2021-06-14 20:34:44 +05:30
docker.rake DEV: Run `yarn install` for all `rake docker:test` invocations (#17844) 2022-08-09 12:28:52 +01:00
emails.rake DEV: Correctly tag heredocs (#16061) 2022-02-28 20:50:55 +01:00
emoji.rake DEV: Upgrade to Rails 7 2022-04-28 11:51:03 +02:00
export.rake
groups.rake
i18n.rake DEV: Update `i18n:check` rake task to detect invalid Markdown links (#13728) 2021-07-14 13:26:12 +02:00
images.rake DEV: Upgrade to Rails 7 2022-04-28 11:51:03 +02:00
import.rake FEATURE: Add last visit indication to topic view page. (#13471) 2021-07-05 14:17:31 +08:00
incoming_emails.rake
integration.rake DEV: Remove hints of jshint (#14828) 2021-11-08 09:12:37 +08:00
javascript.rake DEV: Remove usage of {{action}} modifiers - Take 2 (#18476) 2022-10-05 13:08:54 +01:00
log.rake FIX: whoops, linting 2020-09-03 12:10:11 +01:00
maxminddb.rake
plugin.rake DEV: Add `rake plugins:turbo_spec` task (#18289) 2022-09-20 15:42:54 +01:00
populate.rake DEV: Add ability to populate private messages (#16705) 2022-05-12 14:29:49 -04:00
populate.thor DEV: Correctly tag heredocs (#16061) 2022-02-28 20:50:55 +01:00
posts.rake FIX: Query correct model in posts:inline_uploads (#18330) 2022-09-23 15:00:02 +03:00
qunit.rake DEV: Allow `rake qunit` filter to be used alongside parallel option (#18326) 2022-09-22 10:28:02 +01:00
redis.rake FIX: add support for pipelined and multi redis commands (#16682) 2022-05-10 08:19:02 +10:00
release_note.rake DEV: Print plugin changes in details blocks (#18345) 2022-09-23 10:29:00 -04:00
revisions.rake DEV: Introduce debugging rake task for PostRevision issues (#17998) 2022-08-19 11:30:46 +01:00
rspec.rake
s3.rake DEV: Ensure Ember CLI sourcemaps are uploaded to S3 (#15893) 2022-02-10 19:00:47 +00:00
scheduler.rake
search.rake
site.rake DEV: Fix methods removed in Ruby 3.2 (#15459) 2022-01-05 18:45:08 +01:00
site_settings.rake
smoke_test.rake DEV: Minor linting fixes (#16359) 2022-04-02 21:15:38 +02:00
svg_icons.rake
tags.rake
themes.rake DEV: Only raise `rake themes:update` errors when flag provided (#16254) 2022-03-22 17:02:14 +00:00
topics.rake DEV: Upgrade to Rails 7 2022-04-28 11:51:03 +02:00
turbo.rake
typepad.thor FIX: use allowlist and blocklist terminology (#10209) 2020-07-27 10:23:54 +10:00
uploads.rake DEV: Rename secure_media to secure_uploads (#18376) 2022-09-29 09:24:33 +10:00
users.rake