Skip to content

Add action buttons (Like, Boost) to the reactions block#2988

Merged
pfefferle merged 5 commits intotrunkfrom
add/reaction-action-buttons
Mar 2, 2026
Merged

Add action buttons (Like, Boost) to the reactions block#2988
pfefferle merged 5 commits intotrunkfrom
add/reaction-action-buttons

Conversation

@pfefferle
Copy link
Member

@pfefferle pfefferle commented Mar 2, 2026

Preparation for #2792

Screenshot 2026-03-02 at 13 04 47 Screenshot 2026-03-02 at 13 04 57

Proposed changes:

  • Add optional Like and Boost action buttons inline in each reaction group of the Fediverse Reactions block.
  • Clicking a button opens a full-size modal dialog where visitors can copy the post URL or enter their Fediverse handle to interact from their home server (FEP-3b86, OStatus, and Mastodon fallback).
  • Add posts/{id}/remote-intent REST endpoint returning { url, template } — consistent with the existing remote-follow and remote-reply endpoints.
  • Refactor Webfinger::get_remote_follow_endpoint() to delegate to new get_intent_endpoint() method with FEP-3b86 support.
  • Pass $intent to Interaction Controller filters for extensibility.
  • Reuse the shared modal infrastructure (Blocks::render_modal() + createModalStore()) — the modal dynamically switches between compact (reactors list) and full-size (intent dialog) modes.
  • Feature is opt-in via a showActions block attribute with editor toggle in Inspector Controls.
  • Share saved Fediverse profile across blocks via localStorage (fediverse-remote-user key).

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Go to a post that has existing Fediverse reactions (likes, reposts).
  • Edit the post and select the Reactions block. In the sidebar, enable "Show action buttons".
  • Save and view the post on the frontend.
  • Verify Like/Boost buttons appear inline at the start of each reaction group row.
  • Click a button — a full-size modal should open with two sections: "Post URL" (with copy button) and "Your Profile" (with input field).
  • Enter a valid Fediverse handle (e.g. @user@mastodon.social) and click "Go" — the remote server's interaction page should open in a new tab.
  • Check the "Remember my profile" checkbox, submit, then open a different action button — the profile should be pre-filled.
  • Toggle off "Show action buttons" in the editor — buttons should disappear.
  • Verify the compact reactors list modal (clicking the count label) still works as before.

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Minor

Type

  • Added - for new features

Message

Add optional Like and Boost action buttons to the Fediverse Reactions block, allowing visitors to interact with posts from their own server.

Add optional Like and Boost action buttons to each reaction group in the
Fediverse Reactions block. Clicking a button opens a full-size modal dialog
where visitors can copy the post URL or enter their Fediverse handle to
interact from their home server.

Backend:
- Add remote-intent REST endpoint at posts/{id}/remote-intent
- Add Webfinger::get_intent_endpoint() with FEP-3b86 and OStatus fallback
- Refactor get_remote_follow_endpoint() to delegate to get_intent_endpoint()
- Pass $intent to Interaction Controller filters for extensibility

Frontend:
- Extend the shared modal to switch between compact (reactors list) and
  full-size (intent dialog) modes via context.modal.isCompact
- Add showActions block attribute (opt-in) with editor toggle
- Reuse createModalStore() and Blocks::render_modal() shared infrastructure
- Share localStorage profile with remote-reply block

Includes tests for the new endpoint and Webfinger::get_intent_endpoint().
Copilot AI review requested due to automatic review settings March 2, 2026 12:10
@pfefferle pfefferle self-assigned this Mar 2, 2026
@pfefferle pfefferle requested a review from a team March 2, 2026 12:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds opt-in Like/Boost “remote intent” actions to the Fediverse Reactions block, backed by a new REST endpoint and WebFinger intent discovery (FEP-3b86 with fallbacks).

Changes:

  • Adds posts/{id}/remote-intent REST endpoint and extends WebFinger with get_intent_endpoint() (FEP-3b86 + OStatus + Mastodon fallback).
  • Updates the Reactions block (editor + frontend Interactivity store) to show action buttons and a full-size intent modal with localStorage profile persistence.
  • Extends shared modal rendering to support dynamic titles and compact/full-size switching.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/phpunit/tests/includes/rest/class-test-post-controller.php Adds route registration + response/validation tests for the new remote-intent endpoint.
tests/phpunit/tests/includes/class-test-webfinger.php Adds unit tests for Webfinger::get_intent_endpoint() across supported discovery/fallback paths.
src/reactions/view.js Implements intent modal behavior, REST call, clipboard copy, and localStorage persistence in the Interactivity store.
src/reactions/style.scss Styles the inline action buttons and the intent dialog inside the shared modal.
src/reactions/render.php Adds showActions attribute handling, renders action buttons and the new dual-mode modal contents, and configures i18n/context.
src/reactions/reactions.js Updates editor-side React preview to display (disabled) action buttons when enabled.
src/reactions/edit.js Adds Inspector toggle for the showActions attribute and passes it through to the preview.
src/reactions/block.json Introduces the showActions block attribute.
includes/rest/class-post-controller.php Registers the remote-intent route and implements the { url, template } response.
includes/rest/class-interaction-controller.php Passes $intent through interaction filters for extensibility.
includes/class-webfinger.php Refactors remote-follow to delegate to new intent endpoint discovery with FEP-3b86 support + fallbacks.
includes/class-blocks.php Extends shared modal renderer with title_binding + dynamic compact class binding support.
build/reactions/view.js Built asset reflecting src/reactions/view.js changes.
build/reactions/view.asset.php Updates built asset metadata for the view script.
build/reactions/style-index.css Built CSS reflecting src/reactions/style.scss changes.
build/reactions/style-index-rtl.css Built RTL CSS reflecting src/reactions/style.scss changes.
build/reactions/render.php Built render file reflecting src/reactions/render.php changes.
build/reactions/index.js Built editor script reflecting src/reactions/* changes.
build/reactions/index.asset.php Updates built asset metadata for the editor script.
build/reactions/block.json Built block metadata reflecting src/reactions/block.json changes.
.github/changelog/2988-from-description Adds changelog entry for the feature.

- Wrap $intent_map in showActions conditional to avoid unused variable
- Reuse Webfinger::get_identifier_and_host() for Mastodon fallback URL
  instead of manual host parsing
- Add noopener,noreferrer to window.open for reverse-tabnabbing protection
- Wrap JSON.parse in try/catch for corrupted localStorage data
- Remove quote from intent map since there is no quote intent in FEP-3b86
@pfefferle pfefferle merged commit f196222 into trunk Mar 2, 2026
12 checks passed
@pfefferle pfefferle deleted the add/reaction-action-buttons branch March 2, 2026 16:21
pfefferle added a commit that referenced this pull request Mar 3, 2026
Follow-up to #2988. Fixes avatar overflow on smaller screens when
action buttons are enabled, removes unwanted button hover styles
from the reaction count label, and prevents the full-size intent
modal from being misaligned after a compact dropdown was open.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants