Repository navigation
Boost: Migrate Notice to @wordpress/ui - #48171
Conversation
Replace the Jetpack-internal Notice component (@automattic/jetpack-components) with the compound-component Notice from @wordpress/ui across 11 call sites in Boost. The new API decomposes title/actions/children into Notice.Root / Notice.Title / Notice.Description / Notice.Actions / Notice.CloseIcon, and maps level to intent (same vocabulary). Webpack: bundle @wordpress/theme and @wordpress/private-apis inline — they're transitive deps of @wordpress/ui but are not registered as script handles in WP core for plain admin pages, so externalizing them breaks the enqueue. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
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! Boost plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Follow-up to #48171 (Boost migration). Migrates the three non-Boost call sites of the Jetpack-internal Notice component (from @automattic/jetpack-components) to the compound-component Notice from @wordpress/ui: - Jetpack plugin: _inc/client/components/connection-banner/index.jsx - Protect: src/js/routes/settings/index.jsx (2 notices) - Protect: src/js/routes/firewall/index.jsx (1 notice, previously aliased as JetpackNotice) Each call site decomposes title/actions/children into Notice.Root / Notice.Title / Notice.Description / Notice.Actions / Notice.CloseIcon, and maps `level` -> `intent` (same vocabulary). Adds @wordpress/ui 0.11.0 to projects/plugins/protect/package.json (the Jetpack plugin already had it). Webpack: forces @wordpress/theme to bundle inline in protect's webpack config and in the Jetpack plugin's tools/webpack.config.js DependencyExtractionPlugin() call sites. @wordpress/theme is a transitive dep of @wordpress/ui that isn't registered as a WP script handle in plain admin contexts, so externalizing it breaks enqueue. Leaving @wordpress/private-apis externalized: core's private-apis copy rejects lock() from non-core modules, but other externalized consumers (@wordpress/dataviews) depend on sharing the same instance. The source Notice component in js-packages/components and the my-jetpack package's three call sites are intentionally left unchanged here. my-jetpack pulls in @wordpress/dataviews which fights over the private-apis consent map when @wordpress/theme is bundled inline; that migration needs dedicated webpack surgery and is out of scope for this PR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| @@ -78,6 +78,15 @@ module.exports = [ | |||
| MiniCssExtractPlugin: { | |||
| filename: 'jetpack-boost.css', | |||
| }, | |||
| DependencyExtractionPlugin: { | |||
There was a problem hiding this comment.
the Boost PR's requestMap is a workaround for a WP-core gap (wp-theme isn't a registered handle in plain admin). Without it, the bundle silently doesn't load.
Co-authored-by: Mikael Korpela <mikael@ihminen.org>
…tice-use-wp-ui # Conflicts: # pnpm-lock.yaml # projects/plugins/boost/package.json
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Code Coverage SummaryCoverage changed in 2 files.
|
Follow-up to #48171 (Boost migration). Migrates the three non-Boost call sites of the Jetpack-internal Notice component (from @automattic/jetpack-components) to the compound-component Notice from @wordpress/ui: - Jetpack plugin: _inc/client/components/connection-banner/index.jsx - Protect: src/js/routes/settings/index.jsx (2 notices) - Protect: src/js/routes/firewall/index.jsx (1 notice, previously aliased as JetpackNotice) Each call site decomposes title/actions/children into Notice.Root / Notice.Title / Notice.Description / Notice.Actions / Notice.CloseIcon, and maps `level` -> `intent` (same vocabulary). Adds @wordpress/ui 0.11.0 to projects/plugins/protect/package.json (the Jetpack plugin already had it). Webpack: forces @wordpress/theme to bundle inline in protect's webpack config and in the Jetpack plugin's tools/webpack.config.js DependencyExtractionPlugin() call sites. @wordpress/theme is a transitive dep of @wordpress/ui that isn't registered as a WP script handle in plain admin contexts, so externalizing it breaks enqueue. Leaving @wordpress/private-apis externalized: core's private-apis copy rejects lock() from non-core modules, but other externalized consumers (@wordpress/dataviews) depend on sharing the same instance. The source Notice component in js-packages/components and the my-jetpack package's three call sites are intentionally left unchanged here. my-jetpack pulls in @wordpress/dataviews which fights over the private-apis consent map when @wordpress/theme is bundled inline; that migration needs dedicated webpack surgery and is out of scope for this PR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Follow-up to #48171 (Boost migration). Migrates the three non-Boost call sites of the Jetpack-internal Notice component (from @automattic/jetpack-components) to the compound-component Notice from @wordpress/ui: - Jetpack plugin: _inc/client/components/connection-banner/index.jsx - Protect: src/js/routes/settings/index.jsx (2 notices) - Protect: src/js/routes/firewall/index.jsx (1 notice, previously aliased as JetpackNotice) Each call site decomposes title/actions/children into Notice.Root / Notice.Title / Notice.Description / Notice.Actions / Notice.CloseIcon, and maps `level` -> `intent` (same vocabulary). Adds @wordpress/ui 0.11.0 to projects/plugins/protect/package.json (the Jetpack plugin already had it). Webpack: forces @wordpress/theme to bundle inline in protect's webpack config and in the Jetpack plugin's tools/webpack.config.js DependencyExtractionPlugin() call sites. @wordpress/theme is a transitive dep of @wordpress/ui that isn't registered as a WP script handle in plain admin contexts, so externalizing it breaks enqueue. Leaving @wordpress/private-apis externalized: core's private-apis copy rejects lock() from non-core modules, but other externalized consumers (@wordpress/dataviews) depend on sharing the same instance. The source Notice component in js-packages/components and the my-jetpack package's three call sites are intentionally left unchanged here. my-jetpack pulls in @wordpress/dataviews which fights over the private-apis consent map when @wordpress/theme is bundled inline; that migration needs dedicated webpack surgery and is out of scope for this PR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Components: Migrate remaining Notice consumers to @wordpress/ui Follow-up to #48171 (Boost migration). Migrates the three non-Boost call sites of the Jetpack-internal Notice component (from @automattic/jetpack-components) to the compound-component Notice from @wordpress/ui: - Jetpack plugin: _inc/client/components/connection-banner/index.jsx - Protect: src/js/routes/settings/index.jsx (2 notices) - Protect: src/js/routes/firewall/index.jsx (1 notice, previously aliased as JetpackNotice) Each call site decomposes title/actions/children into Notice.Root / Notice.Title / Notice.Description / Notice.Actions / Notice.CloseIcon, and maps `level` -> `intent` (same vocabulary). Adds @wordpress/ui 0.11.0 to projects/plugins/protect/package.json (the Jetpack plugin already had it). Webpack: forces @wordpress/theme to bundle inline in protect's webpack config and in the Jetpack plugin's tools/webpack.config.js DependencyExtractionPlugin() call sites. @wordpress/theme is a transitive dep of @wordpress/ui that isn't registered as a WP script handle in plain admin contexts, so externalizing it breaks enqueue. Leaving @wordpress/private-apis externalized: core's private-apis copy rejects lock() from non-core modules, but other externalized consumers (@wordpress/dataviews) depend on sharing the same instance. The source Notice component in js-packages/components and the my-jetpack package's three call sites are intentionally left unchanged here. my-jetpack pulls in @wordpress/dataviews which fights over the private-apis consent map when @wordpress/theme is bundled inline; that migration needs dedicated webpack surgery and is out of scope for this PR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Fix CI on #48173: changelog type, webpack indentation, test selector - Jetpack changelog entry: Type `changed` isn't valid for plugins/jetpack (allowed: major, enhancement, compat, bugfix, other). Switch to `other`. - tools/webpack.config.js: fix prettier/prettier indentation inside the DependencyExtractionPlugin requestMap override (the eslint --fix reindent). - connection-banner test: the old test used getByLabelText looking for ActionButton's `label` prop. The @wordpress/ui Notice.ActionButton puts the text in children; switch to getByRole with accessible name. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Drop @wordpress/theme webpack workaround The original migration added `@wordpress/theme: { external: false }` to DependencyExtractionPlugin requestMaps in protect/webpack.config.js and in two call sites in plugins/jetpack/tools/webpack.config.js, on the theory that @wordpress/theme is a transitive dep of @wordpress/ui that isn't registered as a WP script handle in plain admin contexts. Verified locally: with both files restored to trunk, `jetpack build plugins/protect` succeeds and the migrated Notices render cleanly on Protect Settings and Firewall — no console errors, no enqueue failures. @wordpress/theme is shipped as a script module, not a classic script handle, so the externalization concern doesn't apply here. Per @simison's review feedback on #48173. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Address review feedback on Notice migration - firewall/index.jsx: wrap "Jetpack Firewall is currently disabled." in __() so it gets translated (regression introduced when migrating away from the old <Notice title=...> prop, which was already passing a translated string). - settings/index.jsx: replace `target="_blank" rel="noreferrer"` on both Notice.ActionLink instances with the `openInNewTab` shorthand. It's the @wordpress/ui Link API: sets target=_blank under the hood and appends the design system's external-link arrow indicator. Per @simison's review feedback on #48173. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Christian Gastrell <cgastrell@gmail.com>
…shboard build The Notice migration introduced a transitive dep on `@wordpress/theme` via `@wordpress/ui`. The dependency-extraction-webpack-plugin externalized it to the `wp-theme` script handle, which is not reliably registered as a WP script in plain admin contexts (e.g., Jurassic Ninja test sites). When `wp-theme` was missing from `$wp_scripts->registered`, WordPress silently skipped printing `jp-search-dashboard` -- no script tag, no inline initial state, blank page. Bundle both `@wordpress/theme` and `@wordpress/private-apis` together so the module-init `lock()` call lands on the same private-apis consent map. Same fix as #48173 (Components Notice migration) and #48171 (Boost). The search dashboard does not pull in `@wordpress/dataviews`, so this does not hit the my-jetpack collision case described there. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…48537) (#48550) * Search: migrate dashboard notices to @wordpress/ui Notice Replace the local SimpleNotice + NoticeAction wrappers with Notice.* from @wordpress/ui across the search dashboard: - record-meter/notice-box: tier notices use Notice.Root/Title/Description + Notice.Actions/ActionLink (openInNewTab); the legacy jp-search-notice-box__important class becomes intent="error". - pages/sections/first-run-section: indexing notice uses Notice.Root/Title/ Description. - global-notices: snackbar notices use Notice.Root + Notice.Description + Notice.CloseIcon, with auto-dismiss preserved via a useEffect timer. Status strings remain in the redux store; mapped to wp-ui intents at render. Drops vestigial fields the redux notice creators never set anyway (isCompact, isPersistent, displayOnNextPage, notice.button/href). Deletes the SimpleNotice/NoticeAction sources, their stylesheets, and notice-box.scss; strips the dead .dops-notice* overrides from global-notices/style.scss while keeping the snackbar positioning rules. Removes one site of @automattic/jetpack-components Gridicon usage (SimpleNotice's icon-wrapper) — helps the broader modernization sweep. Follow-up to simison review feedback on #48537. * Search: scope notice-box test queries to render container `@wordpress/ui` Notice uses `@wordpress/a11y` to announce notice text via `<div class="a11y-speak-region">` regions appended to `document.body`. After this PR's migration, the notice copy is in the DOM twice (in the rendered Notice and in the body-level a11y-speak live region), so `screen.getByText` throws "Found multiple elements". Capture the `container` from `render()` and use `within( container ).getByText(...)` so queries only see the rendered Notice and ignore the screen-reader announcement region that lives outside the container. Verified locally: all 5 tests in `notice-box.test.jsx` pass. * Search: bundle @wordpress/theme and @wordpress/private-apis in the dashboard build The Notice migration introduced a transitive dep on `@wordpress/theme` via `@wordpress/ui`. The dependency-extraction-webpack-plugin externalized it to the `wp-theme` script handle, which is not reliably registered as a WP script in plain admin contexts (e.g., Jurassic Ninja test sites). When `wp-theme` was missing from `$wp_scripts->registered`, WordPress silently skipped printing `jp-search-dashboard` -- no script tag, no inline initial state, blank page. Bundle both `@wordpress/theme` and `@wordpress/private-apis` together so the module-init `lock()` call lands on the same private-apis consent map. Same fix as #48173 (Components Notice migration) and #48171 (Boost). The search dashboard does not pull in `@wordpress/dataviews`, so this does not hit the my-jetpack collision case described there. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Search: fix changelogger Type for jetpack plugin entry The jetpack plugin's changelogger uses bugfix/enhancement/compat/major/other taxonomy, not fixed/changed/added/removed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fixes #
Proposed changes
Migrates Jetpack Boost's 11
Noticecall sites from the internal@automattic/jetpack-componentscomponent to the compound-componentNoticefrom@wordpress/ui.Swap the
Noticeimport for the compound-componentNoticenamespace from@wordpress/ui.Translate the old flat props into sub-components:
level="error|warning|info|success"intent="error|warning|info|success|neutral"onNotice.Roottitle="X"<Notice.Title>X</Notice.Title>children(body)<Notice.Description>…</Notice.Description>actions={[…]}<Notice.Actions>wrappingNotice.ActionButton/Notice.ActionLinkhideCloseButton={true}<Notice.CloseIcon>onClose={fn}<Notice.CloseIcon onClick={fn} label="Dismiss" />Add
"@wordpress/ui": "0.9.0"toprojects/plugins/boost/package.json(matches sibling packages).Override webpack's
DependencyExtractionPlugin.requestMapto bundle@wordpress/themeand@wordpress/private-apisinline. They're transitive deps of@wordpress/uithat the plugin would otherwise externalize to thewp-theme/wp-private-apisscript handles — butwp-themeisn't registered by WP core for plain admin pages, so externalizing it silently breaks the Boost admin bundle enqueue.Files touched (11 call sites):
boost-pricing-table,cornerstone-pages/meta,critical-css/regenerate-critical-css-suggestion,critical-css/show-stopper-error,image-guide,lcp/status/error-details,minify-legacy-notice,module,page-cache/health/error-notices(11 Notices in one file),page-cache/meta,page-cache.Before:

After:

Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
jetpack build plugins/boost --deps.wp-admin → Jetpack → Booston a test site.worksOffline: falseshows the "This module will not work while your website is not publicly available." Notice with the new@wordpress/uistyling (amber warning background, caution icon) when the site is not publicly reachable.pnpm eslint projects/plugins/boost/app/assets/src/js/features— should be clean.Follow-up: the matching migration for the Jetpack plugin's
connection-banner, along with themy-jetpackandprotectconsumers, plus deletion of the source component fromjs-packages/components, will land in a separate PR.