Skip to content

Social: per-connection message template editor (SOCIAL-451)#48564

Merged
manzoorwanijk merged 1 commit into
trunkfrom
add/social-451-per-connection-template-editor
May 6, 2026
Merged

Social: per-connection message template editor (SOCIAL-451)#48564
manzoorwanijk merged 1 commit into
trunkfrom
add/social-451-per-connection-template-editor

Conversation

@manzoorwanijk
Copy link
Copy Markdown
Member

@manzoorwanijk manzoorwanijk commented May 6, 2026

Fixes SOCIAL-451

Note

Stacked on top of #48560. Easier to review the deltas there: add/social-message-template-editors...add/social-451-per-connection-template-editor

Proposed changes

Surfaces the per-connection template field (server-side wiring landed in #48522) in two places on the Social admin page, both anchored under the row that exposes the Disconnect button so users find it where they already go to manage a connection:

  • Inline list — inside each connection's collapsible panel on the Social admin page, below the "Mark the connection as shared" row and above Disconnect.
  • Manage Jetpack Social connections modal — under each existing connection's row in the services list. Opens via "Connect an account" → expand a service → see the connection rows.

Both surfaces render the same new ConnectionTemplateEditor, which wraps the shared MessageTemplateEditor from #48560 and auto-saves through updateConnectionById after a 1s debounce. Both stay in sync for free since they read/write through the same connection-data store slice.

Gating (all three required):

  • social-message-templates feature flag.
  • social-enhanced-publishing paid plan.
  • canUserManageConnection capability check.

If any one is missing, the editor is simply hidden — no read-only fallback in this iteration.

Save behaviour mirrors the polish that landed in the SOCIAL-450 PR after review:

  • The textarea is not disabled while a save is in flight; the connections endpoint is "last write wins" so concurrent saves resolve fine without freezing the UI on each keystroke pause.
  • A lastSentRef guards the useEffect re-sync so a slow save resolving while the user is still typing past the debounce window doesn't clobber their in-progress edits with the just-confirmed earlier value.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  • Connect a site that has both social-message-templates and social-enhanced-publishing features active.
  • Go to Jetpack → Social (/wp-admin/admin.php?page=jetpack-social).
  • Inline test:
    • Expand any connection's row by clicking the chevron on the right.
    • Confirm a "Custom message for this connection" textarea appears below "Mark the connection as shared" and above Disconnect.
    • Type a custom template; pause; a POST /wp-json/wpcom/v2/publicize/connections/{id} should fire with {"template":"..."} and return 201.
    • Reload the page and re-expand — the saved value hydrates back into the textarea.
  • Modal test:
    • Click "Connect an account".
    • Click the chevron next to a service that already has connections (e.g. Bluesky, Facebook).
    • Confirm the same editor renders below each existing connection's "Disconnect" row, with the same auto-save behaviour.
    • Edit the template in the modal; close the modal; expand the same connection in the inline list — value should be in sync without a reload.
  • Gate tests:
    • Switch to a user without edit_others_posts (so canUserManageConnection is false for connections owned by others) — the editor should be hidden for those connections.
    • Drop the social-enhanced-publishing feature on the test site — the editor should disappear from both surfaces.
    • Drop social-message-templates — same.
Screenshot 2026-05-06 at 2 50 47 PM
Screenshot 2026-05-06 at 2 50 37 PM

@manzoorwanijk manzoorwanijk self-assigned this May 6, 2026
@manzoorwanijk manzoorwanijk requested a review from gmjuhasz May 6, 2026 10:09
@manzoorwanijk manzoorwanijk added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. labels May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the add/social-451-per-connection-template-editor branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/social-451-per-connection-template-editor

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@jp-launch-control
Copy link
Copy Markdown

jp-launch-control Bot commented May 6, 2026

Code Coverage Summary

1 file is newly checked for coverage.

File Coverage
projects/packages/publicize/_inc/components/connection-management/connection-template/index.tsx 20/25 (80.00%) 💚

Full summary · PHP report · JS report

Base automatically changed from add/social-message-template-editors to trunk May 6, 2026 10:46
Implements SOCIAL-451. Surfaces the per-connection \`template\` field
(server-side wiring landed in #48522) in two places on the Social admin
page, both anchored to the row that exposes the Disconnect button:

* Inline list — inside each connection's collapsible panel under the
  "Mark the connection as shared" row, above Disconnect.
* Manage Jetpack Social connections modal — under each existing
  connection's row in the services list (the row that also shows the
  Disconnect button), surfacing the editor in the same place users
  already go to manage a connection.

Both surfaces render the new ConnectionTemplateEditor, which wraps the
shared MessageTemplateEditor and auto-saves through updateConnectionById
after a 1s debounce. Both stay in sync for free since they read/write
through the same connection-data store slice.

Gating:

* social-message-templates feature is required.
* social-enhanced-publishing (paid plan) is required.
* canUserManageConnection capability check.

If any of the three doesn't hold, the editor is simply hidden — no
read-only fallback. Clearing an existing override remains possible via
the same editor when a downgraded user re-upgrades; clearing without
the plan is intentionally out of scope for this iteration.

Tests cover the four gating paths. The existing ServiceConnectionInfo
tests pick up a stub ConnectionTemplateEditor mock so they don't need
the social store.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@manzoorwanijk manzoorwanijk force-pushed the add/social-451-per-connection-template-editor branch from 87cd9a6 to 86fdb31 Compare May 6, 2026 10:49
Copy link
Copy Markdown
Contributor

@gmjuhasz gmjuhasz left a comment

Choose a reason for hiding this comment

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

This works good, the disabling of the whole row while typing feels quite clunky, but we agreed to patch that in a followup p1778070097013599-slack-C0ATW4VK6JH

@manzoorwanijk manzoorwanijk merged commit d4d3b2f into trunk May 6, 2026
82 of 83 checks passed
@manzoorwanijk manzoorwanijk deleted the add/social-451-per-connection-template-editor branch May 6, 2026 12:27
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Review This PR is ready for review. labels May 6, 2026
LiamSarsfield pushed a commit that referenced this pull request May 6, 2026
Implements SOCIAL-451. Surfaces the per-connection \`template\` field
(server-side wiring landed in #48522) in two places on the Social admin
page, both anchored to the row that exposes the Disconnect button:

* Inline list — inside each connection's collapsible panel under the
  "Mark the connection as shared" row, above Disconnect.
* Manage Jetpack Social connections modal — under each existing
  connection's row in the services list (the row that also shows the
  Disconnect button), surfacing the editor in the same place users
  already go to manage a connection.

Both surfaces render the new ConnectionTemplateEditor, which wraps the
shared MessageTemplateEditor and auto-saves through updateConnectionById
after a 1s debounce. Both stay in sync for free since they read/write
through the same connection-data store slice.

Gating:

* social-message-templates feature is required.
* social-enhanced-publishing (paid plan) is required.
* canUserManageConnection capability check.

If any of the three doesn't hold, the editor is simply hidden — no
read-only fallback. Clearing an existing override remains possible via
the same editor when a downgraded user re-upgrades; clearing without
the plan is intentionally out of scope for this iteration.

Tests cover the four gating paths. The existing ServiceConnectionInfo
tests pick up a stub ConnectionTemplateEditor mock so they don't need
the social store.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Feature] Publicize Now Jetpack Social, auto-sharing [Package] Publicize [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants