Repository navigation
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 7 files. Only the first 5 are listed here.
Full summary · PHP report · JS report Coverage check overridden by
Covered by non-unit tests
|
|
@enejb - I updated the description to link this to the linear issue |
8b42fe7 to
4b2cc76
Compare
4b2cc76 to
eee81d3
Compare
… drop a non-text kind, and let the Blaze icon fetch fail quietly
|
The issue with this approach is that the CSS is coming from calypso and we could end up in the state where the CSS pollutes the global scope. We explored another PR #55113 which uses an iframe to contain the css just to the scope of this PR but then you end up changing the feature, since the UI shows the sidebar. I am closing this approach for now. |
Fixes JETPACK-3745
Proposed changes
Exploratory. With the
jetpack-admin-shellflag on, Jetpack → Blaze Ads opens inside the admin shell, without a page load, like the other Jetpack dashboards. Blaze itself is not rewritten: it's still the Calypso bundle loaded from widgets.wp.com.Admin shell (
packages/admin-ui)scriptmember kind for pages that aren't built with wp-build. A script member declares the element its scripts mount into (container:idand optionalclass) instead of the wp-build keys. The shell creates that element, then runs the page's own scripts through the guest endpoint, and the scripts boot the page. Hovering its menu link starts the download early.boot-layoutwrappers, so the page gets the same frame, rounded stage and loading state as the wp-build dashboards. The copied stage gets a stablejetpack-admin-shell__stageclass for the page's own CSS, since boot's class names are hashed.div, span, a, li, ul, h1, button { margin: 0; padding: 0; … }), and@wordpress/uistyles live in@layer wp-ui.components, so the reset restyled tabs, toggles and buttons on every other dashboard once Blaze had loaded.popstatethe shell sends after a switch now carries no state. TanStack readshistoryitself, and calypso-router throws on another router's state but re-reads the URL on a null one.Blaze (
packages/blaze)scriptmember when it sits in the Jetpack menu. Not on Simple sites, when the dashboard is disabled, when Blaze can't initialize, or when the standalone Blaze Ads plugin owns the menu. Only when the installed admin-ui knows thescriptkind..jetpack-admin-shell__stage, Calypso's.promote-post-i2__pagegetsmin-height: calc(100vh - admin bar - 8px)instead of100vh - admin bar, so it no longer overflows the stage by the 8px gap below it. The rule sits on the dashboard's stylesheet, so it also loads (and switches off) with Blaze in the shell.render()printed (icon sprite + hashbang links) is now plain JS attached to the dashboard script withwp_add_inline_script(), so it also runs inside the shell. Behavior on a normal page load is unchanged.Known gaps (exploratory):
is-section-promote-post-i2body class and--color-*variables on<html>stay after Blaze has loaded; nothing visible depends on them with its stylesheet off.Test coverage: the PHP member validation has unit tests, and the client has a test for switching a hidden page's stylesheets off. The rest is the page boot, the router hand-off and the direct-load frame, which only show up in a real browser with the Calypso bundle, so the rehearsals below cover them instead (hence
Covered by non-unit tests).Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Rehearsals
Run the rehearsals below from Tools → Rehearsal on any Jurassic Ninja site with the shell flag on. They work in both setups below (with Jetpack, or VideoPress + Blaze Ads) and cover: opening Blaze from another dashboard without a page load, Blaze's styles staying off the other dashboards (and the second visit having no console errors), and the direct load drawing the rounded frame. The prose steps cover what they can't: looks, the flag-off path and links inside Blaze.
Rehearsal: Blaze Ads: Opens from another Jetpack dashboard without a page load
Rehearsal
f357d90· 6 steps · coverspackages/admin-ui,packages/blaze,packages/my-jetpackLast run: Passed on WordPress 7.1.4 · Theme: Twenty Twenty-Four 1.6 · Akismet Anti-spam: Spam Protection 5.7.2 · Blaze Ads 0.9.0 · Jetpack VideoPress 3.8, run #18, 2026-11-12.
View or install this rehearsal · JSON · Playwright test (links work while wildly-residential.jurassic.ninja exists)
Rehearsal JSON
{ "format": 2, "requires": [ "jetpack or jetpack-videopress", "jetpack or blaze-ads" ], "covers": [ "packages/admin-ui", "packages/blaze", "packages/my-jetpack" ], "viewport": "desktop", "timeout": 30000, "steps": [ { "goto": "/wp-admin/admin.php?page=my-jetpack" }, { "expect": "[data-shell-page=\"my-jetpack\"][data-shell-state=\"visible\"]", "toHaveCount": 1 }, { "click": "#adminmenu a:has-text(\"Blaze Ads\")" }, { "expect": "[data-shell-state=\"visible\"] h1:has-text(\"Blaze Ads\")", "toBeVisible": true }, { "expect": "[data-shell-page=\"my-jetpack\"][data-shell-state=\"hidden\"]", "toHaveCount": 1 }, { "expectNoConsoleErrors": true } ] }Rehearsal: Blaze Ads: Its styles stay off the other Jetpack dashboards
Rehearsal
e1db83c· 12 steps · coverspackages/admin-ui,packages/blaze,packages/my-jetpackLast run: Passed on WordPress 7.1.4 · Theme: Twenty Twenty-Four 1.6 · Akismet Anti-spam: Spam Protection 5.7.2 · Blaze Ads 0.9.0 · Jetpack VideoPress 3.8, run #19, 2026-11-12.
View or install this rehearsal · JSON · Playwright test (links work while wildly-residential.jurassic.ninja exists)
Rehearsal JSON
{ "format": 2, "requires": [ "jetpack or jetpack-videopress", "jetpack or blaze-ads" ], "covers": [ "packages/admin-ui", "packages/blaze", "packages/my-jetpack" ], "viewport": "desktop", "timeout": 30000, "steps": [ { "goto": "/wp-admin/admin.php?page=my-jetpack" }, { "expect": "[data-shell-page=\"my-jetpack\"][data-shell-state=\"visible\"]", "toHaveCount": 1 }, { "click": "#adminmenu a:has-text(\"Blaze Ads\")" }, { "expect": "[data-shell-state=\"visible\"] h1:has-text(\"Blaze Ads\")", "toBeVisible": true }, { "click": "#adminmenu a:has-text(\"My Jetpack\")" }, { "expect": "[data-shell-page=\"my-jetpack\"][data-shell-state=\"visible\"]", "toHaveCount": 1 }, { "expect": "link[href*=\"blaze-dashboard\"][disabled]", "toHaveCount": 1 }, { "expect": "[data-shell-page=\"my-jetpack\"] [role=tab]:has-text(\"Overview\")", "toBeVisible": true }, { "click": "#adminmenu a:has-text(\"Blaze Ads\")" }, { "expect": "[data-shell-state=\"visible\"] h1:has-text(\"Blaze Ads\")", "toBeVisible": true }, { "expect": "link[href*=\"blaze-dashboard\"]:not([disabled])", "toHaveCount": 1 }, { "expectNoConsoleErrors": true } ] }Rehearsal: Blaze Ads: Loads in the rounded Jetpack frame
Rehearsal
0893b2e· 4 steps · coverspackages/admin-ui,packages/blazeLast run: Passed on WordPress 7.1.4 · Theme: Twenty Twenty-Four 1.6 · Akismet Anti-spam: Spam Protection 5.7.2 · Blaze Ads 0.9.0 · Jetpack VideoPress 3.8, run #20, 2026-11-12.
View or install this rehearsal · JSON · Playwright test (links work while wildly-residential.jurassic.ninja exists)
Rehearsal JSON
{ "format": 2, "requires": [ "jetpack or jetpack-videopress", "jetpack or blaze-ads" ], "covers": [ "packages/admin-ui", "packages/blaze" ], "viewport": "desktop", "timeout": 30000, "steps": [ { "goto": "/wp-admin/admin.php?page=advertising" }, { "expect": "#wpcom h1:has-text(\"Blaze Ads\")", "toBeVisible": true }, { "expect": "[class*=\"-frame__stage\"] #wpcom h1:has-text(\"Blaze Ads\")", "toBeVisible": true }, { "expectNoConsoleErrors": true } ] }With the Jetpack plugin
wp companion feature-flag enable jetpack-admin-shellon Jurassic Ninja, oradd_filter( 'jetpack_admin_shell_enabled', '__return_true' );.page=advertisingwithout a page load. The empty white rounded stage shows, then the Blaze dashboard renders in it (no grey GIF spinner, no square corners).reading 'replace'error in the console.wp-admin/admin.php?page=advertisingdirectly. Blaze loads in the same rounded frame as Jetpack → Protect: its stage starts at the same spot, is the same size, and shows all four corners. Links inside it (Campaigns, Payments, Promote) still work.&jetpack_admin_shell_debug=1to log each switch in the console.Without the Jetpack plugin (VideoPress + Blaze Ads)
This checks that Blaze joins the shell through another plugin's copy of the packages. Blaze Ads 0.9.0 bundles
jetpack-blaze0.27.0 and puts Blaze under Tools, so this setup swaps in this branch's package and moves Blaze under the Jetpack menu with a test-only mu-plugin. Shipping that for real needs a change in Automattic/blaze-ads after ajetpack-blazerelease.On the same connected site, build the VideoPress plugin from this branch (
jetpack build --deps plugins/videopress), install and activate it, then deactivate Jetpack.Install and activate Blaze Ads from WordPress.org. Replace
wp-content/plugins/blaze-ads/vendor/automattic/jetpack-blaze/srcandbuildwith this branch'sprojects/packages/blaze/srcandbuild.Keep the shell flag on and
JETPACK_AUTOLOAD_DEVdefined, so this branch's admin-ui from VideoPress is the copy that loads.Add this test-only mu-plugin:
wp-content/mu-plugins/1-blaze-ads-under-jetpack-menu.phpGo to Jetpack → My Jetpack. The Jetpack menu lists My Jetpack, Activity Log, Blaze Ads and VideoPress.
Click Jetpack → Blaze Ads. The address changes to
page=wp-blazewithout a page load, and Blaze renders in the rounded stage. It's in Blaze Ads mode: blue theme, no Jetpack logo, "Blaze Ads" in the footer.Click Jetpack → VideoPress. It looks as it does without visiting Blaze: no Calypso fonts or reset on its tabs and buttons.
Open
wp-admin/admin.php?page=wp-blazedirectly. Blaze loads in the rounded frame.To restore: activate Jetpack and delete the mu-plugin; reinstalling Blaze Ads brings back its own
jetpack-blaze.