Add EditorCapabilityResolver to centralize editor-capability gating#22812
Open
jkmassel wants to merge 1 commit intojkmassel/site-settings-rustfrom
Open
Add EditorCapabilityResolver to centralize editor-capability gating#22812jkmassel wants to merge 1 commit intojkmassel/site-settings-rustfrom
jkmassel wants to merge 1 commit intojkmassel/site-settings-rustfrom
Conversation
Contributor
|
|
Contributor
|
|
Contributor
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
6968ec2 to
7af2cc5
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## jkmassel/site-settings-rust #22812 +/- ##
===============================================================
+ Coverage 37.18% 37.20% +0.02%
===============================================================
Files 2317 2318 +1
Lines 124468 124507 +39
Branches 16896 16906 +10
===============================================================
+ Hits 46280 46321 +41
+ Misses 74444 74442 -2
Partials 3744 3744 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
`SiteSettingsFragment` combined the top-level GutenbergKit feature flag, the remote `gutenberg_kit_plugins` flag, the per-site capability cache, and the user's toggle inline — a long conditional chain per capability that's hard to share with other consumers and easy to drift from when those consumers get added. Introduces `EditorCapabilityResolver` as a single source of truth for both theme styles and third-party blocks. Returns a `Resolved` sealed result — `Hidden` / `Unsupported(reason)` / `Available(userEnabled, advisory?)` — that UI callers branch on directly, and non-UI callers collapse via `shouldApplyInEditor`. The theme-not-a-block-theme case is modelled as an advisory, not a gate, matching today's behaviour where the pref stays enabled with an informational summary. Wires `SiteSettingsFragment` through the resolver. The editor-side consumer (the GutenbergKit config builder) will land in a follow-up alongside its refactor to an injectable class.
7af2cc5 to
34887ae
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
EditorCapabilityResolveras the single source of truth for whether the theme-styles and third-party-blocks capabilities apply to a site, combining the top-level GutenbergKit feature flag, the remotegutenberg_kit_pluginsflag, the per-site capability cache (EditorSettingsRepository), and the user's per-site toggle (SiteSettingsProvider).Resolvedsealed hierarchy (Hidden/Unsupported(reason)/Available(userEnabled, advisory?)) that UI callers can branch on directly to pick the right visibility / disabled-with-reason / advisory-note treatment. Non-UI callers collapse the state viashouldApplyInEditor.Available, not a gate — the pref stays enabled with an informational summary, matching today's behaviour.SiteSettingsFragmentthrough the resolver, replacing two inline conditional chains with pattern matches overResolved.Extracted from #22579 — the editor-side consumer (the GutenbergKit config builder) will land in that PR alongside its refactor to an injectable class, so the preloading PR only shows the editor-facing plumbing.
Test plan
./gradlew :WordPress:testJetpackDebugUnitTest --tests "org.wordpress.android.ui.posts.EditorCapabilityResolverTest"passes (17 tests covering the decision tree for both capabilities)experimental_block_editorfeature flag off — both prefs hiddenRelated