refactor(emails): move Emails from Settings to Audience Configuration#4759
Conversation
There was a problem hiding this comment.
Pull request overview
Moves the unified Emails management UI from Newspack → Settings to Audience → Configuration as the last tab. The Emails screen itself (chips, DataViews, registry, preview thumbnails, toggle behavior) is unchanged; REST API paths remain stable via a hardcoded REST_BASE constant on Emails_Section, and a small inline redirect forwards bookmarks from the old hash URL to the new one.
Changes:
- Re-registers the
Emails_Sectionunder the Audience wizard (class-wizards.php,class-audience-wizard.php) while keeping the REST namespacewizard/newspack-settings/emailsfor backwards compatibility. - Removes the Emails tab/data from the Settings wizard (PHP localized data, TS types, sections registry) and adds it to the Audience wizard (route, tab, localized
window.newspackAudience.emails). - Adds an inline redirect on the old Settings page from
#/emailsto the new Audience URL, plus a minor typo fix insettings.tsx("transacitonal" → "transactional").
Reviewed changes
Copilot reviewed 10 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| includes/class-wizards.php | Moves Emails_Section registration from Settings to Audience wizard. |
| includes/wizards/audience/class-audience-wizard.php | Accepts $args in constructor; localizes emails data on window.newspackAudience. |
| includes/wizards/newspack/class-emails-section.php | Switches wizard_slug to newspack-audience; introduces REST_BASE constant to preserve API path. |
| includes/wizards/newspack/class-newspack-settings.php | Removes Emails tab data; adds inline JS redirect for old bookmarks. |
| src/wizards/audience/views/setup/index.js | Adds Emails tab and route to Audience setup. |
| src/wizards/audience/views/setup/emails/index.tsx | Reads new window.newspackAudience.emails shape; wraps screen with withWizardScreen. |
| src/wizards/audience/views/setup/emails/emails.tsx | Reads emails config from window.newspackAudience instead of window.newspackSettings. |
| src/wizards/audience/views/setup/emails/settings.tsx | Header doc update; fixes "transacitonal" typo. |
| src/wizards/audience/views/setup/emails/emails.test.js | Updates mock to new window.newspackAudience.emails shape. |
| src/wizards/audience/views/setup/emails/email-preview.tsx / .scss / .test.js | New EmailPreview component, styles, and tests (preview path uses stable newspack-settings/emails REST base). |
| src/wizards/audience/views/setup/emails/emails.scss | Emails tab layout, chips, and trigger description styles. |
| src/wizards/newspack/views/settings/sections.tsx | Removes Emails import and section component mapping. |
| src/wizards/newspack/types/index.d.ts | Drops Emails entry from window.newspackSettings types. |
| src/wizards/types/window.d.ts | Adds emails entry to window.newspackAudience types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3410271 to
643cb6d
Compare
bfb86d3 to
a420a31
Compare
…NPPD-1538) Move the Emails management UI from Newspack > Settings > Emails to Audience > Configuration > Emails as the last tab. REST API paths remain stable at /wizard/newspack-settings/emails via a hardcoded REST_BASE constant for backward compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a420a31 to
8b01984
Compare
643cb6d to
43a03aa
Compare
|
Closing in favor of the monorepo rebuild. After The rebuild preserves this PR's core intent (move the Emails screen from Newspack > Settings to Audience > Configuration) and adds several refinements that emerged during the consolidation work it now ships alongside:
The rebuild also caught two endpoints ( No code is lost; all logic from this PR has equivalent or improved coverage in the replacement. |
What this PR does
Moves the unified Emails management UI from Newspack → Settings → Emails to Audience → Configuration → Emails, where it sits alongside the other audience-configuration surfaces (NPPD-1538).
Nav-and-routing change only. The Emails screen itself (chips, DataViews, registry, preview thumbnails, toggle behavior) is unchanged. The REST API also stays at its existing path so no external callers break.
Final piece of the project's UI consolidation work — Emails now lives where publishers will look for it.
Depends on slice 2 (#4732), NPPD-1524 (#4756), and NPPD-1537 (#4758) — branched off that stack and inherits their changes.
Code changes
Backend —
includes/wizards/newspack/class-emails-section.php$wizard_slugchanged from'newspack-settings'to'newspack-audience'so the section registers under the Audience wizardREST_BASEconstant hardcoded to'wizard/newspack-settings/emails'with a docblock explaining the historical naming for API stability. Allregister_rest_route()calls useself::REST_BASEinstead of deriving from$wizard_slug— REST routes stay at their existing paths regardless of which parent wizard owns the admin screenBackend —
includes/class-wizards.php'emails'section from thenewspack-settingswizard instantiation'emails'section to theaudiencewizard via the new$argsparameterBackend —
includes/wizards/audience/class-audience-wizard.php$argstoparent::__construct()so sections can be passed inenqueue_scripts_and_styles()localizes the emails config (isEmailEnhancementsActive, dependencies, postType) ontowindow.newspackAudience.emailsBackend —
includes/wizards/newspack/class-newspack-settings.phpemailsblock fromget_local_data()and dropped the now-unused imports (Emails,Reader_Revenue_Emails,WooCommerce_Emails)window.location.hash === '#/emails', redirects toadmin.php?page=newspack-audience#/emailsbefore React mounts. Handles old bookmarks without a server-side redirect (the hash fragment is invisible to PHP)Frontend —
src/wizards/audience/views/setup/emails/(moved fromsrc/wizards/newspack/views/settings/emails/)index.tsx,emails.tsx,settings.tsx,email-preview.tsx,email-preview.scss, plus their tests. Directory nesting depth is unchanged, so existing relative imports continue resolving correctly without path editsindex.tsx: data source switched fromwindow.newspackSettings.emails.sections.emails.isEmailEnhancementsActiveto the flattenedwindow.newspackAudience.emails.isEmailEnhancementsActiveemails.tsx: reads config fromwindow.newspackAudience.emailsFrontend —
src/wizards/audience/views/setup/index.jsEmailsimport, appended the "Emails" tab unconditionally (matches current Settings behavior — screen contents continue to adapt viaisEmailEnhancementsActive)/emailsrouteFrontend —
src/wizards/newspack/views/settings/sections.tsxEmailsimport and theemailsentry from the sections mappingFrontend — TypeScript
src/wizards/types/window.d.ts: addedemailsproperty to thenewspackAudienceinterfacesrc/wizards/newspack/types/index.d.ts: removedemailsfrom thenewspackSettingsinterfaceFrontend — Tests
src/wizards/audience/views/setup/emails/emails.test.js: updated mock setup fromwindow.newspackSettingstowindow.newspackAudiencewith the flattened structureemail-preview.test.js: existing mock paths unchanged (REST API paths stayed put)Why this PR
The Emails management UI has grown into a comprehensive audience-configuration surface (registry, chips, WC integration, preview thumbnails, card expiry warning, branded WC Subs delivery). It belongs alongside the other Audience → Configuration screens — Configuration, Checkout & Payment, and eventually Access Control.
The single non-obvious choice in this PR is keeping the REST API at the old path (
wizard/newspack-settings/emails). The motivation: REST paths are part of the contract with external callers (Newspack Manager, third-party integrations, tooling). Moving them would break things outside this repo for no UX benefit. The frontend doesn't care which path the API lives at — it just hits whatever path is configured.Manual testing
Tested locally with Newspack, WooCommerce, WooCommerce Subscriptions, and the WC Block Email Editor feature enabled. Verified:
admin.php?page=newspack-settings#/emailsredirects toadmin.php?page=newspack-audience#/emails/newspack/v1/wizard/newspack-settings/emails(confirmed via network tab and direct curl)Note: 3 pre-existing TypeScript warnings on DataViews generics carried over from trunk — not introduced by this PR.
PHPUnit, Jest (49 suites / 438 tests), and webpack all green locally; PHPCS clean on changed files.
All Submissions: