Commit Graph

9 Commits

Author SHA1 Message Date
Simon Backx
3a11faf0b6 Updated publishing with renamed newsletter and email_segment options (#2380)
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.
2022-05-16 10:18:46 +02:00
Simon Backx
98e80cb6f8 Replaced newsletterId usage with newsletter
refs https://github.com/TryGhost/Team/issues/1569
refs https://github.com/TryGhost/Team/issues/1596
refs https://github.com/TryGhost/Team/issues/1576

- Removed some usages of post.newsletterId with post.newsletter
- Renamed newsletterId adapterOption from newsletterId to newsletter, in preparation of https://github.com/TryGhost/Team/issues/1596 (still sending newsletter_id)
- Removed newsletterId property of post model
2022-05-10 13:56:30 +02:00
Kevin Ansfield
adeef741fb Added first iteration of saving to new publish flow
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
2022-05-04 10:30:45 +01:00
Kevin Ansfield
e5c26aac89 Added newsletter dropdown to publish menu
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
2022-04-06 10:22:06 +01:00
Gabriel Csapo
fdc24103cc [chore] runs native classes codemod for app/adapters (#2239)
no issue

* ran native classes codemod for app/adapters
* migrated slug-url mixin to a utility
2022-02-02 16:57:22 +00:00
Kevin Ansfield
0caa539330 Added label and product options for email recipients (#1947)
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
2021-05-07 11:58:05 +01:00
Rishabh Garg
49b86b466a Allowed sending newsletter to free members only (#1751)
refs 6140a98351

This officially decouples the newsletter recipients from the post visibility allowing us to send emails to free members only.
2020-11-07 00:24:27 +05:30
Kevin Ansfield
6fe159c8d9 Updated handling of send_email_when_published
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
2019-11-14 17:33:35 +00:00
Kevin Ansfield
a0a0c50ff5 Removed use of ?include=tags,authors,authors.roles query param on post/page requests
no issue
- Admin API v2 now includes tags and authors by default
2019-02-25 21:55:55 +07:00