Social: per-connection message template editor (SOCIAL-451)#48564
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage Summary1 file is newly checked for coverage.
|
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>
87cd9a6 to
86fdb31
Compare
gmjuhasz
left a comment
There was a problem hiding this comment.
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
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>
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
templatefield (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:Both surfaces render the same new
ConnectionTemplateEditor, which wraps the sharedMessageTemplateEditorfrom #48560 and auto-saves throughupdateConnectionByIdafter a 1s debounce. Both stay in sync for free since they read/write through the sameconnection-datastore slice.Gating (all three required):
social-message-templatesfeature flag.social-enhanced-publishingpaid plan.canUserManageConnectioncapability 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:
lastSentRefguards theuseEffectre-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
social-message-templatesandsocial-enhanced-publishingfeatures active./wp-admin/admin.php?page=jetpack-social).POST /wp-json/wpcom/v2/publicize/connections/{id}should fire with{"template":"..."}and return201.edit_others_posts(socanUserManageConnectionis false for connections owned by others) — the editor should be hidden for those connections.social-enhanced-publishingfeature on the test site — the editor should disappear from both surfaces.social-message-templates— same.