Subscriptions: add "Send as email" toggle#34592
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 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
There was a problem hiding this comment.
This setting felt flaky, so commented it out. If it doesn't work, we can remove for now and add back in separate PR.
jeherve
left a comment
There was a problem hiding this comment.
This works well for me, but I don't know if the wording for that setting is clear enough. At first, I thought the toggle was related to the preview email below:
- Maybe there should be a separator between the 2?
- Maybe the parts that do not apply anymore get removed when you toggle off the email?
- What if instead of a toggle, we had a "none" option as a radio, something like this?
|
@jeherve thanks! Yep, we're working still on the wording and structure of the pre-publish and post-publish panels for this 👍 It definitely needs some adjustments. |
That panel controls access, which is somewhat separate from whom we send the emails, albeit very related. I.e. the access also affects how you see blog posts, posts in the Reader, etc. Hence the setting should be separate. |
58863bb to
79cc12d
Compare
There was a problem hiding this comment.
Note that this was old meta field I'm re-using for backwards compatibility, but it was never registered like this:
https://github.com/search?q=repo%3AAutomattic%2Fjetpack%20_jetpack_dont_email_post_to_subs&type=code
3e521ed to
042218b
Compare
f4fb279 to
fbaf854
Compare
fbaf854 to
d43f61f
Compare
lezama
left a comment
There was a problem hiding this comment.
Tested and works great and everything makes much more sense than before.
Feel free to keep polishing but Approving in case you want to merge 😄
| const showMisconfigurationWarning = getShowMisconfigurationWarning( postVisibility, accessLevel ); | ||
|
|
||
| { shouldLoadSubscriptionPlaceholder && ( | ||
| const isSendEmailEnabled = useSelect( select => { |
There was a problem hiding this comment.
In a follow-up, I'd like this in a re-usable React hook.
| return ( | ||
| <ToggleControl | ||
| checked={ isSendEmailEnabled } | ||
| disabled={ isPostPublished || ! canEdit } |
There was a problem hiding this comment.
In a follow-up we should check if the post was published already previously and set the toggle disabled. Prior art:
jetpack/projects/plugins/jetpack/modules/subscriptions.php
Lines 1047 to 1062 in 2f325ae
jetpack/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.js
Lines 110 to 114 in 2f325ae
I tried it briefly but it felt flaky, so better in separate PR.
Resolves Automattic/wp-calypso#44263
Resolves #10876
Adds "Send as email" toggle:
(FYI Below screenshots are outdated)
Proposed changes:
The feature pre-existed before Gutenberg, so the backend was already handled in Jetpack.
Previously the toggle was "negated", i.e. checking it to "not send email". Clearer UX is to do something when toggle is enabled, hence the meta and toggle handling seem a bit backwards.
TODO: PR needs some minor work in pre/post-publish panel copies and to check if post was published previously.



Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
Create a new post
In post settings, leave toggle enabled and publish the post.
Note pre-publish panel toggle — you can try change it, go back to post panel, etc.
Note copy at pre-publish panel.
Post gets sent as an email
The toggle should be disabled now and in truthy setting (the email was already sent)

Create another post, leave toggle disabled and publish the post
Note copy at pre-publish panel.
No email was sent
The toggle should be disabled now and in falsy setting (no way to send email now that post was published)