Skip to content

fix(newsletters): activate ads in one step from status toggle#479

Merged
adekbadek merged 4 commits into
mainfrom
fix/nl-ads-status-onestep
Jul 20, 2026
Merged

fix(newsletters): activate ads in one step from status toggle#479
adekbadek merged 4 commits into
mainfrom
fix/nl-ads-status-onestep

Conversation

@adekbadek

@adekbadek adekbadek commented Jul 1, 2026

Copy link
Copy Markdown
Member

Changes proposed in this Pull Request:

Follow-up to #476 (ad editor Active/Inactive control) and #478 (ads list Quick Edit status), both merged.

1. One-step activation. Review feedback on the editor control: picking Active only set intent — the publisher then had to click WP's native Publish button, which opens the pre-publish confirmation exposing "Visibility: Public / Publish: Immediately". That's the exact WP vocabulary the Active/Inactive control is meant to abstract away, leaking through a two-step flow. This makes the toggle a true on/off switch: selecting Active/Inactive applies and persists the status in one step (editPost + savePost), the same immediate-commit model as the list Quick Edit. Because activation no longer routes through the native Publish button, the pre-publish panel (and its raw Visibility/Publish wording) never appears.

Disabling the pre-publish panel via disablePublishSidebar() was rejected: that setting lives in the global core preferences scope, so it would suppress pre-publish checks for posts and newsletters too.

2. Date advisories moved into the sidebar. Because one-step activation bypasses the native Publish flow, the date advisories that were only rendered in PluginPrePublishPanel (expiration in the past, expiry before start, or the display-window summary) would otherwise never be seen. They now also render as a Notice at the top of the Ad settings panel, visible during normal editing and activation.

How to test the changes in this Pull Request:

  1. Open a draft Newsletter Ad in the editor.
  2. In Ad settings, click Status → Active. Confirm it activates immediately — no pre-publish panel, no "Visibility / Publish" wording — and persists (reload; post_status is publish, the list shows Active).
  3. Click Status → Inactive and confirm it saves straight to draft the same way.
  4. Set an expiration date in the past (or an expiry before the start date). Confirm a warning notice appears at the top of the Ad settings panel ("This ad will not be displayed…") without needing to open the native Publish flow.

Other information:

  • Have you successfully run tests with your changes locally? (ESLint clean via wp-scripts lint-js; verified end-to-end in an isolated env — one-click Active/Inactive commits to publish/draft with no pre-publish panel, and the date advisory renders in the sidebar.)

@adekbadek
adekbadek requested a review from a team as a code owner July 1, 2026 10:20
Copilot AI review requested due to automatic review settings July 1, 2026 10:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Newspack Newsletters “Newsletter Ad” editor so the Active/Inactive status control becomes a true one-step toggle by immediately persisting the corresponding post_status change (publish/draft) via editPost() + savePost(), avoiding the native Publish flow and its pre-publish vocabulary.

Changes:

  • Dispatch savePost() from the editor status control so toggling Active/Inactive commits immediately.
  • Keep the editor’s custom status abstraction (Active/Inactive) as the only surfaced status UI while bypassing the native Publish button workflow.

Comment thread plugins/newspack-newsletters/src/ads/editor/index.js
adekbadek and others added 2 commits July 1, 2026 12:30
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@adekbadek
adekbadek force-pushed the fix/nl-ads-status-onestep branch from f178317 to eab5720 Compare July 1, 2026 10:31
@adekbadek
adekbadek changed the base branch from release to main July 1, 2026 10:31

@dkoo dkoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, well-scoped change — makes the Newsletter Ad status toggle a true one-step switch. I verified it end-to-end in an isolated env: Active commits to publish and Inactive to draft in a single step with no pre-publish panel (both DB-confirmed), and a past expiration date surfaces the warning Notice at the top of the Ad settings sidebar. No blockers.

The editPost({ status }) + savePost() idiom is correct: @wordpress/data dispatches synchronously, so savePost() persists the just-set status, and this matches the existing disable-auto-ads.js pattern. Two non-blocking notes inline.

Release risk: LOW — single editor-JS file, no PHP/contract/schema surface, verified against a running env.

Comment thread plugins/newspack-newsletters/src/ads/editor/index.js
Comment thread plugins/newspack-newsletters/src/ads/editor/index.js
@github-actions github-actions Bot added [Status] Approved Pull request has been approved and removed [Status] Needs Review labels Jul 16, 2026
@adekbadek
adekbadek merged commit e0eb747 into main Jul 20, 2026
10 checks passed
@adekbadek
adekbadek deleted the fix/nl-ads-status-onestep branch July 20, 2026 13:29
@github-actions

Copy link
Copy Markdown

Hey @adekbadek, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-changelog [Status] Approved Pull request has been approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants