Skip to content

Security Settings: Import ToggleControl from @wordpress/components - #48179

Merged
CGastrell merged 1 commit into
trunkfrom
claude/practical-galileo-14bf1c
Apr 19, 2026
Merged

CGastrell merged 1 commit into
trunkfrom
claude/practical-galileo-14bf1c

Conversation

@ilonagl

@ilonagl ilonagl commented Apr 18, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

  • Move the ToggleControl import in projects/plugins/jetpack/_inc/client/security/waf.jsx, sso.jsx, and allowList.jsx from @automattic/jetpack-components to @wordpress/components — 7 call sites total.
  • Add __nextHasNoMarginBottom={ true } on every migrated <ToggleControl> so the bottom margin matches the default the jetpack-components wrapper was setting, and the upstream deprecation warning stays quiet.
  • Drop the wrapper-only toggling prop from the 7 migrated sites. The upstream @wordpress/components ToggleControl has no equivalent. The user-visible loss is the brief optimistic knob-flip + 0.6 opacity dim during the save round-trip on WAF / Allow List / SSO toggles. See the follow-up note below for a functional gap (rapid-re-click guard) that should be closed in a later PR.

Part of #48160. Follows the consumer-only migration shape of #48170 (RadioControl).

Out of scope

  • The ToggleControl wrapper in projects/js-packages/components/components/toggle-control/ (and its re-export from the package index.ts) is intentionally left in place — other consumers still use it, and removing it is a separate concern.
  • The ModuleToggle wrapper at _inc/client/components/module-toggle/index.jsx also still imports ToggleControl from @automattic/jetpack-components; its migration will be a follow-up PR (it changes behavior for account-protection.jsx, monitor.jsx, protect.jsx, and the module-level rows on waf.jsx / sso.jsx).

Follow-up (to address in a later PR)

The removed toggling prop also short-circuited onChange while a save was in flight, acting as a rapid-re-click guard. The existing disabled={ … } guards on the migrated toggles do not fully replace that:

  • WAF / Allow List toggles (5 sites): baseInputDisabledCase checks isFetchingWafSettings and isSavingAnyOption([ 'waf' ]), but not isUpdatingWafSettings. Those are separate Redux slices — isUpdatingWafSettings lives in state.jetpack.waf.requests (flipped by WAF_SETTINGS_UPDATE / _SUCCESS / _FAIL), while isSavingAnyOption reads state.jetpack.settings.requests.settingsSent, which updateWafSettings does not populate. So the toggle stays enabled during the WAF-settings round-trip.
  • SSO toggles (2 sites): the old toggling checked the specific option key (jetpack_sso_match_by_email / jetpack_sso_require_two_step), but disabled only checks the module key (sso). Different entries in settingsSent — same gap.

Impact: minor. Saves are fast (~200–500ms), duplicate updates are idempotent, and WAF_SETTINGS_UPDATE_SUCCESS overwrites local state with the server response (last-write-wins). Worst case is a brief UI flicker if the user rapid-clicks and responses arrive out of order. No data risk.

Suggested fix in the follow-up PR:

  • waf.jsx / allowList.jsx: add this.props.isUpdatingWafSettings to baseInputDisabledCase.
  • sso.jsx: OR isSavingAnyOption([ 'jetpack_sso_match_by_email' ]) / isSavingAnyOption([ 'jetpack_sso_require_two_step' ]) into each toggle's disabled.

Does this pull request change what data or activity we track or use?

No.

Screenshots

Before / after on a live Jurassic Ninja site, with Firewall enabled so all the migrated toggles are visible. The two images are byte-identical (same SHA-256) — the change is a pure import swap with no rendered-at-rest difference. The toggling UX regression (optimistic flip + dim) only appears during the save round-trip and cannot be captured in a static screenshot.

Surface Before (trunk baseline on JN) After (this branch on JN)
Security settings (full page) before after

JN rsync target: plugins/jetpack · Baseline: trunk · JN site: thoughtfully-remarkable-device.jurassic.ninja

Testing instructions

  • Changelog entry added for projects/plugins/jetpack.
  • On a Jetpack site, go to Jetpack → Settings → Security. Enable Firewall. Confirm all inner toggles render identically to trunk: Automatic rules, Manual rules (IP block list), Share basic data, Share detailed data, Always allowed IP addresses (allow list), and the SSO toggles under WordPress.com login (Match accounts by email, Require Two-Step).
  • Flip each migrated toggle once and verify the setting persists across reload — this exercises the disabled-based in-flight guard that replaces the removed toggling prop.
  • Check the browser console on the Security page: no ToggleControl margin-related deprecation warnings should appear.

Migrate the `ToggleControl` usages in the Jetpack Security settings
(WAF, Allow List, SSO) off the `@automattic/jetpack-components`
wrapper and onto `@wordpress/components` directly.

- Add `__nextHasNoMarginBottom` on every call site so margin matches
  what the wrapper was setting by default and no deprecation warning
  fires.
- Drop the wrapper's `toggling` prop (not present on the upstream
  component). Existing `disabled` guards keep repeat submissions from
  firing while settings are in flight; the only user-visible loss is
  the short optimistic-flip / dim effect during the save round-trip.

The `@automattic/jetpack-components` wrapper and its other consumers
(including the ModuleToggle wrapper used elsewhere on the same
page) are intentionally left alone — separate follow-up.

Part of #48160.
@github-actions

github-actions Bot commented Apr 18, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the claude/practical-galileo-14bf1c branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack claude/practical-galileo-14bf1c

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Admin Page React-powered dashboard under the Jetpack menu labels Apr 18, 2026
@github-actions

github-actions Bot commented Apr 18, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: May 5, 2026
    • Code freeze: May 4, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report · JS report

@CGastrell CGastrell added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Apr 19, 2026
@github-actions github-actions Bot added [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Apr 19, 2026
@CGastrell
CGastrell marked this pull request as ready for review April 19, 2026 15:31
@dhasilva dhasilva added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Apr 19, 2026
@dhasilva
dhasilva requested a review from a team April 19, 2026 16:47
@CGastrell
CGastrell merged commit 094454e into trunk Apr 19, 2026
84 checks passed
@CGastrell
CGastrell deleted the claude/practical-galileo-14bf1c branch April 19, 2026 20:32
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Apr 19, 2026
@github-actions github-actions Bot added this to the jetpack/15.8 milestone Apr 19, 2026
CGastrell added a commit that referenced this pull request Apr 20, 2026
Switch the ToggleControl rendered by the shared ModuleToggle wrapper
from @automattic/jetpack-components to @wordpress/components, in line
with PRs #48177 / #48179 / #48189 / #48190 / #48186.

- Add __nextHasNoMarginBottom so spacing matches the prior wrapper
  default and no deprecation warning fires.
- Drop the wrapper toggling prop (not present on the upstream
  component) and remove the now-dead toggling= lines from every
  <ModuleToggle> consumer. For each consumer, the saving condition
  was folded into the existing disabled expression so click-blocking
  during a save is preserved (only the optimistic-flip / dim animation
  is lost). Each call site was inspected individually rather than
  bulk-edited.

Direct <ToggleControl> consumers that still import from
@automattic/jetpack-components (newsletter/subscriptions-settings, the
inner toggles in earn/ads.jsx, line 170 of newsletter/newsletter.jsx)
are intentionally left alone -- separate follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CGastrell added a commit that referenced this pull request Apr 23, 2026
…48207)

Migrate the 10 direct <ToggleControl> call sites in the Monetize (Ads)
settings off the @automattic/jetpack-components wrapper and onto
@wordpress/components, matching PRs #48177 / #48179 / #48189 / #48190
/ #48186.

- Split the import so ToggleControl comes from @wordpress/components
  alongside ExternalLink.
- Add __nextHasNoMarginBottom on every call site so margin matches the
  prior default and no deprecation warning fires.
- Drop the toggling prop (not present on the upstream component) and
  fold each option key into the existing disabled clause alongside
  'wordads', so click-blocking during a save is preserved. The only
  user-visible loss is the short optimistic-flip / dim animation.

The <ModuleToggle slug="wordads"> above these toggles is intentionally
left alone -- it belongs to the ModuleToggle migration in PR #48197.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CGastrell added a commit that referenced this pull request Apr 24, 2026
Switch the ToggleControl rendered by the shared ModuleToggle wrapper
from @automattic/jetpack-components to @wordpress/components, in line
with PRs #48177 / #48179 / #48189 / #48190 / #48186.

- Add __nextHasNoMarginBottom so spacing matches the prior wrapper
  default and no deprecation warning fires.
- Drop the wrapper toggling prop (not present on the upstream
  component) and remove the now-dead toggling= lines from every
  <ModuleToggle> consumer. For each consumer, the saving condition
  was folded into the existing disabled expression so click-blocking
  during a save is preserved (only the optimistic-flip / dim animation
  is lost). Each call site was inspected individually rather than
  bulk-edited.

Direct <ToggleControl> consumers that still import from
@automattic/jetpack-components (newsletter/subscriptions-settings, the
inner toggles in earn/ads.jsx, line 170 of newsletter/newsletter.jsx)
are intentionally left alone -- separate follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CGastrell added a commit that referenced this pull request Apr 24, 2026
…ts (#48197)

Switch the ToggleControl rendered by the shared ModuleToggle wrapper
from @automattic/jetpack-components to @wordpress/components, in line
with PRs #48177 / #48179 / #48189 / #48190 / #48186.

- Add __nextHasNoMarginBottom so spacing matches the prior wrapper
  default and no deprecation warning fires.
- Drop the wrapper toggling prop (not present on the upstream
  component) and remove the now-dead toggling= lines from every
  <ModuleToggle> consumer. For each consumer, the saving condition
  was folded into the existing disabled expression so click-blocking
  during a save is preserved (only the optimistic-flip / dim animation
  is lost). Each call site was inspected individually rather than
  bulk-edited.

Direct <ToggleControl> consumers that still import from
@automattic/jetpack-components (newsletter/subscriptions-settings, the
inner toggles in earn/ads.jsx, line 170 of newsletter/newsletter.jsx)
are intentionally left alone -- separate follow-up.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Admin Page React-powered dashboard under the Jetpack menu [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants