The publish and preview flags don't work as expected for a number of reasons:

  • Toggling the "Content visibility" checkbox has no effect. When this is checked it should set the article as isPreview=true in Apple News. When unchecked it should set the article as isPreview=false in Apple News.
  • Unchecking "Publish to Apple News" should delete the article in Apple News. You shouldn't have to first click through the delete link and do that before Unchecking "Publish to Apple News" really un-publishes it completely from Apple News.
  • Unpublished nodes should either not be sent to Apple News at all until they are published, or enforce the article to be published with isPreview=false
  • If a node becomes unpublished, it should be either deleted or marked as isPreview=true in Apple News
  • When "Publish to Apple News" is checked, the details element should be expanded to make it clear to the user that the article is in Apple News.
  • Simplify the labeling of "Content visibility" checkbox to "Preview" to be more straightforward and line up with the Apple News API
  • Automatically switch out of Preview mode when content changes from unpublished to published to mitigate content editors forgetting this step.
  • Notify the user of any automatic changes to "Preview" status

Comments

m4olivei created an issue. See original summary.

m4olivei’s picture

Issue summary: View changes

  • m4olivei committed 25fc919 on 3060012-publish-preview-flag-work
    Issue #3060012 Enforce preview when we can determine that the entity is...
  • m4olivei committed 98dd1f3 on 3060012-publish-preview-flag-work
    Issue #3060012 Enforce AppleNews article deletion when Publish to Apple...
  • m4olivei committed 9ffc6fc on 3060012-publish-preview-flag-work
    Issue #3060012 Respect the is_preview flag on applenews fields
    
  • m4olivei committed ca25062 on 3060012-publish-preview-flag-work
    Issue #3060012 Open the Apple News settings when the article is...

  • m4olivei committed 9e90155 on 3060012-publish-preview-flag-work
    Issue #3060012 Adjustments to \Drupal\applenews\ApplenewsManager::...
m4olivei’s picture

Status: Active » Needs review
StatusFileSize
new16.88 KB

Here is a patch to accomplish all of the points in the description. Where the choice was between deleting the article in Apple News or marking it isPreview=false, I opted for isPreview=false.

  • m4olivei committed 9f407ca on 3060012-publish-preview-flag-work
    Issue #3060012 Adjust automatic behavior so that it automatically...
m4olivei’s picture

Issue summary: View changes
StatusFileSize
new18.53 KB

Slight adjustments based on user acceptance testing.

m4olivei’s picture

StatusFileSize
new17.91 KB

Reroll

  • m4olivei committed 0bb5006 on 3060012-publish-preview-flag-work
    Issue #3060012 Detect live to preview transitions and delete the article...
m4olivei’s picture

StatusFileSize
new18.41 KB
new948 bytes

Turns out the Apple News API doesn't let you put a live article back into preview mode, from their docs:

Additionally, on update, you can make a preview article public (change true to false), but you cannot set a currently public article back to a preview state (change false to true).

https://developer.apple.com/documentation/apple_news/update_an_article

As such, here is a change to detect when an article is being updated from live to preview and deletes the article from Apple News first before proceeding to create the article as preview.

rokit88’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed and tested.

  • m4olivei committed 092d679 on 8.x-1.x
    Issue #3060012 by m4olivei: Publish and preview don't work as expected...
m4olivei’s picture

Assigned: m4olivei » Unassigned
Status: Reviewed & tested by the community » Fixed

Thanks! Merged to 8.x-1.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.