refs https://github.com/TryGhost/Team/issues/1596
This commit updates admin to align with the changes in the backend in https://github.com/TryGhost/Ghost/pull/14798
- `post.email_recipient_filter` option and property is renamed to `email_segment`
- `newsletter_id` option is renamed to `newsletter` (and now uses slug instead of id)
- Sending a post via email, means you need to set the `newsletter` option. The `email_segment` option is optional now and defaults to `all`. Not setting `newsletter` means not sending an email, setting `email_segment` is ignored if `newsletter` is missing.
- We can no longer use `email_recipient_filter` (now renamed to `email_segment`) to know whether a post is published/scheduled to be sent as an email. We need to rely on the newsletter relation now. The `email_segment` `none` value has been dropped and will be `all` even if no email will be sent (newsletter will be null).
- `sendEmailWhenPublished` option is no longer supported in the backend.
refs https://github.com/TryGhost/Team/issues/1542
- extracted before/after save routines in the editor controller into separate actions
- allows saving to occur in the publish flow without it needing any editor-specific knowledge
- allows for easier cleanup of email related logic from the editor save tasks later on
- added `saveTask` to `PublishOptions`
- applies the selected options to the post model where they correspond to model attributes and keeps the previous values in memory so the changes can be undone on failure - this keeps the local model state in sync because if a publish fails we want the editor to continue showing the draft state, non-scheduled publish time, and not have an unexpected email-only state
- saves the post model directly passing `adapterOptions` so the save request query params match the chosen publish options
- added a `saveTask` to the `<PublishManagement>` component
- passed through to the `publish-flow` modal and is triggered by the confirm button on the confirmation screen
- runs the before/afterSave arguments passed in from the editor
- runs the `saveTask` on `PublishOptions` which handles everything needed to change status and send emails
- polls the post after saving to wait for the attached email to switch to submitted/failed which lets us show a failure message and retry button as required (message + retry not yet implemented)
- adds "complete" state to publish flow once save has finished
- confirms what just happened based on saved post data rather than chosen publish options
- has a link to the view the post
closes https://github.com/TryGhost/Team/issues/1479
- updated post adapter to append `?newsletter_id=xyz` when passed a `newsletterId` adapterOption
- updated editor save task to pass `options.newsletterId` through as `adapterOptions.newsletterId`
- set up `post.newsletter` relationship ready for handling embedded newsletter association from the API
- explicitly deleted when serializing back to the API as it doesn't yet ignore the attribute
- updated `<GhPublishmenu>` for newsletter support
- fetches newsletters on first render so they are available in the dropdown
- sets "default" (first in the ordered list) newsletter as the initially selected newsletter
- adds newsletter dropdown to draft publish menu
- passes `newsletterId` option to editor save task when it's set
This is a minimal implementation for testing. Not included:
- correct free/paid member counts based on selected newsletter
- correct member count in confirmation modal
- indication of selected newsletter for scheduled post
refs https://github.com/TryGhost/Team/issues/581
requires https://github.com/TryGhost/Ghost/pull/12932
- added segment option and select to default newsletter recipients setting
- updated segment selector to fetch labels/products and show as options
- updated segment selector and count component to call an action when count changes so we can use it in the email confirmation modal
- removed usage and mapping of older `'none'`, `'all'`, `'free'`, and `'paid'` email recipient filter values
refs 5fd2b7fed1
- sends `?send_email_when_published=true` query param when scheduling/publishing a post with the toggle turned on
- adds support to the posts adapter for handling the `adapterOptions` option
- updates the editor `save` task to pass through the required adapter option when a post is being published or scheduled with the toggle checked
- moves state for the email toggle into the publish menu so that we don't try to toggle the model attribute which should only be fetched from the API
- prevent `post.send_email_when_published` being sent to the API via the serializer as it's now a read-only attribute