mastodon/app/views/admin
Matt Jankowski 4fa462a9f8 Extract form batch classes for relationships and follow recommendations
Related to - https://github.com/mastodon/mastodon/pull/35458 - which added a batch base class, and to - https://github.com/mastodon/mastodon/pull/35872 - which envisions a world where form objects tell the view what to do.

Background here...

- The `Form::AccountBatch` form object is used in a few different places, for somewhat varied purposes
- The user relationships view uses it on a show page, which does a PUT to update, and uses the `follow`, `unfollow`, `remove_from_followers`, and `remove_domains_from_followers` "actions" of the form model
- The admin accounts view shows a form on index view, does POST to batch action, uses the `suspend`, `approve` and `reject` actions.
- The admin relationships view (for admins only) also has a form on index and does a POST back to that same spot
- The admin/follow_recommendations page has a form on show and does PUT to update, using the `suppress_follow_recommendation` and `unsuppress_follow_recommendation` actions

So, while these are all related in that they supply an `accounts_ids` array, the actual things that they "bulk update" are Follow (from relationships), FollowRecommendationSuppression (from follow recs) and Account (from accounts). This is a little inconsistent with other of the "batch form model" classes, which tend to update the same domain concept (ie, CustomEmojiBlock, IpBlockBatch, EmailDomainBlockBatch, etc) that they are named after (and in some cases that a "filter" class is named after).

All that said, the changes here:

- Pull out `Form::FollowRecommendationBatch` and `Form::RelationshipBatch` classes, which more closely align with the domain concept they are bulk updating (open to naming suggestions here)
- Mark both of these as `persisted?` true so that their form views will infer correct HTTP action
- Add some missing coverage to existing class, and coverage for new classes as well

It would be pretty straightforward to chop this up into smaller pieces, if any of "just the coverage first", "just the boolean attribute", "one new batch class at a time", etc - were more appealing.

Possible follow-up:

- In the existing `Form::AccountBatch`, use attributes API for boolean `select_all_matching` value, remove query method
- Convert the relationships controller spec to mix of request/system specs, round out coverage
- Most (all maybe?) of the "batch actions" are doing a `POST` to a `batch` action on the controller of whatever they are related to. Might be worth looking at what the diff would look like to move these all to nested controllers where they did a `PUT to */batches#update` with restful routing, etc.
2025-08-25 10:31:37 -04:00
..
account_actions Fix inability to locally suspend remotely-suspended accounts in moderation interface (#31899) 2024-09-13 09:11:10 +00:00
account_warnings Add material design icons to admin/settings views (#27780) 2024-04-23 16:43:49 +00:00
accounts Prefer delegated nil-wrapping methods to safe navigation (#35541) 2025-07-28 08:03:23 +00:00
action_logs Move admin action log type list generation to helper (#32178) 2024-10-02 14:47:00 +00:00
announcements Add paragraph to tell admins that email announcements cannot be opted out (#34411) 2025-04-11 09:52:23 +00:00
change_emails Fix more haml-lint Rubocop (#24107) 2023-03-15 20:07:43 +01:00
custom_emojis Order emoji categories (in admin interface) by name (#33630) 2025-01-22 08:31:51 +00:00
dashboard Fix: prevent linking to pages which require extra permissions (#32843) 2024-11-12 08:55:17 +00:00
disputes/appeals Use async_count in more view locations (#32086) 2024-10-04 12:29:43 +00:00
domain_allows Consolidate inclusion of admin js pack link (#26628) 2023-08-24 09:56:23 +02:00
domain_blocks Change design of edit media modal in web UI (#33516) 2025-01-21 11:34:22 +00:00
email_domain_blocks Add DomainResource class to wrap MX lookup/normalize (#32864) 2024-11-14 13:47:29 +00:00
export_domain_allows Fix haml-lint LineLength cops in app/views/admin (#28680) 2024-03-15 11:19:00 +00:00
export_domain_blocks Convert form_for -> form_with in views (#30700) 2024-06-14 09:54:22 +00:00
fasp Basic FASP support (#34031) 2025-03-28 12:16:40 +00:00
follow_recommendations Extract form batch classes for relationships and follow recommendations 2025-08-25 10:31:37 -04:00
instances Add minute resolution to DeliveryFailureTracker (#35625) 2025-08-01 13:29:22 +00:00
invites Fix missing button styles on some forms (#33771) 2025-01-29 10:36:24 +00:00
ip_blocks Convert form_for -> form_with in views (#30700) 2024-06-14 09:54:22 +00:00
relationships Convert form_for -> form_with in views (#30700) 2024-06-14 09:54:22 +00:00
relays Change design of edit media modal in web UI (#33516) 2025-01-21 11:34:22 +00:00
report_notes Implement Instance Moderation Notes (#31529) 2025-06-25 08:15:44 +00:00
reports Refactor to reuse the one status partial across moderation tools (#35644) 2025-08-21 14:51:11 +00:00
roles Remove role color highlighting from custom css (#33493) 2025-01-07 16:28:35 +00:00
rules Change rule translation interface to display english name and populate empty translations (#35170) 2025-06-25 10:02:19 +00:00
settings Add setting to control the referrer origin (#34731) 2025-05-19 13:13:22 +00:00
shared Refactor to reuse the one status partial across moderation tools (#35644) 2025-08-21 14:51:11 +00:00
software_updates Solve simplest haml-lint Rubocop lints (#27529) 2023-10-25 12:38:01 +00:00
status_edits Refactor to reuse the one status partial across moderation tools (#35644) 2025-08-21 14:51:11 +00:00
statuses Refactor to reuse the one status partial across moderation tools (#35644) 2025-08-21 14:51:11 +00:00
tags Change design of edit media modal in web UI (#33516) 2025-01-21 11:34:22 +00:00
terms_of_service Change terms of service generator to not be displayed (#35127) 2025-06-26 13:26:41 +00:00
trends Fix up the off by one error on displayed rank for trending tags admin page. (#34016) 2025-02-28 11:16:49 +00:00
username_blocks Add ability to block words in usernames (#35407) 2025-07-29 10:19:15 +00:00
users/roles Add link to /admin/roles in moderation interface when changing someone's role (#31791) 2024-09-06 17:21:49 +00:00
warning_presets Use material symbols in table link helper (#31359) 2024-08-20 11:48:15 +00:00
webhooks Wrap webhook event label with samp tag (#32115) 2024-09-27 08:20:21 +00:00