Show Pro-only General/AI settings as disabled#329
Conversation
Pro-locked settings in the free plugin looked active, which was confusing. - Docs URL Structure: mute the label, dropdown and one-line description; drop the PRO badge; condense the free help text to a single line. - Enable image analysis: mute the label, toggle text and notes; drop badge. - Enable Social Share: drop the redundant PRO badge. All gated by `wedocs_pro_loaded`, so styling reverts when Pro is active.
WalkthroughThis PR updates text color styling from indigo/darker gray to lighter gray across three components, removes PRO badge elements from AiImageAnalysisPreview and SocialShareSettings, and adds conditional rendering in GeneralSettings based on the wedocs_pro_loaded filter. ChangesUI Styling and Badge Cleanup
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/components/Settings/GeneralSettings.js (1)
31-67: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winDead code: non-pro branch of
renderUrlStructureDescriptionis unreachable.
renderUrlStructureDescription()is only called at Line 189, inside theapplyFilters('wedocs_pro_loaded', false) ? ... : ...branch that already requiresisProLoadedto betrue(Line 187). Since the function itself re-checksisProLoaded(Line 33/38), itselsebranch (Lines 51-66, the newly muted gray-400 code blocks) can never execute — the non-pro UI instead falls through to the plain string at Line 198.The styling update at Lines 55-61 has no effect in practice. Either simplify
renderUrlStructureDescriptionto drop the unreachable branch, or restructure the outer ternary so the muted code-block variant is actually used for the non-pro case.♻️ Suggested cleanup
const renderUrlStructureDescription = () => { const siteUrl = (window.weDocsAdminVars?.siteUrl || '/').replace(/\/$/, ''); - const isProLoaded = applyFilters('wedocs_pro_loaded', false); const activeStructure = generalSettings?.docs_url_structure === 'after_doc' ? 'after_doc' : 'before_doc'; const beforeDocUrl = `${siteUrl}/docs/{doc}/{section}/{article}/`; const afterDocUrl = `${siteUrl}/{doc}/docs/{section}/{article}/`; - if (isProLoaded) { - return ( - <span className="block"> - {activeStructure === 'after_doc' - ? __('After Doc: ', 'wedocs') - : __('Before Doc: ', 'wedocs')} - <code className="text-indigo-700 bg-gray-50 px-1 py-0.5 rounded break-all"> - {activeStructure === 'after_doc' ? afterDocUrl : beforeDocUrl} - </code> - </span> - ); - } - - return ( - <> - ... - </> - ); + return ( + <span className="block"> + {activeStructure === 'after_doc' + ? __('After Doc: ', 'wedocs') + : __('Before Doc: ', 'wedocs')} + <code className="text-indigo-700 bg-gray-50 px-1 py-0.5 rounded break-all"> + {activeStructure === 'after_doc' ? afterDocUrl : beforeDocUrl} + </code> + </span> + ); };Also applies to: 186-199
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/Settings/GeneralSettings.js` around lines 31 - 67, `renderUrlStructureDescription` in `GeneralSettings` has an unreachable non-pro branch because the caller already gates on `applyFilters('wedocs_pro_loaded', false)`, so the muted gray-400 code blocks never render. Simplify the helper by removing the redundant `isProLoaded` check and dead `else` branch, or move the non-pro rendering into the outer `wedocs_pro_loaded` ternary so both states are actually used. Keep the logic centered around `renderUrlStructureDescription`, `generalSettings.docs_url_structure`, and the `applyFilters('wedocs_pro_loaded', false)` condition.src/components/ProPreviews/SocialShareSettings.js (1)
29-33: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winLabel not muted after PRO badge removal.
The badge was removed but the "Enable Social Share" label (Line 29) still uses
text-gray-600, same as fully active settings. UnlikeAiImageAnalysisPreview(label muted totext-gray-400) and the "Docs URL Structure" label inGeneralSettings.js(conditionally muted viawedocs_pro_loaded), this control now has no visual indication it's Pro-only, contradicting the PR's stated goal that these settings "no longer appear active next to real settings."💡 Suggested fix
- className="block text-sm font-medium text-gray-600" + className={`block text-sm font-medium ${applyFilters('wedocs_pro_loaded', false) ? 'text-gray-600' : 'text-gray-400'}`}Also applies to: 58-58
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/ProPreviews/SocialShareSettings.js` around lines 29 - 33, The “Enable Social Share” label in SocialShareSettings still looks active because it uses the same text color as enabled settings; update the label styling so this Pro-only control is visually muted, matching the behavior used in AiImageAnalysisPreview and the conditional muted styling in GeneralSettings.js. Locate the label rendering in SocialShareSettings and change its class handling so it no longer appears active next to real settings.
🧹 Nitpick comments (1)
src/components/Settings/GeneralSettings.js (1)
124-199: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueConsolidate repeated
applyFilters('wedocs_pro_loaded', false)calls.The same filter is invoked independently at Lines 33, 124, 127, 158-159, 186, and 187 within a single render. Hoisting it into one
const isProLoaded = applyFilters('wedocs_pro_loaded', false);near the top of the component (and passing it intorenderUrlStructureDescription) would avoid redundant hook traversal and keep the gating logic in one place.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/Settings/GeneralSettings.js` around lines 124 - 199, The `GeneralSettings` render is calling `applyFilters('wedocs_pro_loaded', false)` repeatedly in multiple places, including the Docs URL Structure label, badge, description, and gating branches. Hoist this into a single `const isProLoaded = applyFilters('wedocs_pro_loaded', false);` near the top of the component, then reuse `isProLoaded` throughout and pass it into `renderUrlStructureDescription` so the pro-state logic is centralized and the filter isn’t traversed redundantly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/components/ProPreviews/SocialShareSettings.js`:
- Around line 29-33: The “Enable Social Share” label in SocialShareSettings
still looks active because it uses the same text color as enabled settings;
update the label styling so this Pro-only control is visually muted, matching
the behavior used in AiImageAnalysisPreview and the conditional muted styling in
GeneralSettings.js. Locate the label rendering in SocialShareSettings and change
its class handling so it no longer appears active next to real settings.
In `@src/components/Settings/GeneralSettings.js`:
- Around line 31-67: `renderUrlStructureDescription` in `GeneralSettings` has an
unreachable non-pro branch because the caller already gates on
`applyFilters('wedocs_pro_loaded', false)`, so the muted gray-400 code blocks
never render. Simplify the helper by removing the redundant `isProLoaded` check
and dead `else` branch, or move the non-pro rendering into the outer
`wedocs_pro_loaded` ternary so both states are actually used. Keep the logic
centered around `renderUrlStructureDescription`,
`generalSettings.docs_url_structure`, and the `applyFilters('wedocs_pro_loaded',
false)` condition.
---
Nitpick comments:
In `@src/components/Settings/GeneralSettings.js`:
- Around line 124-199: The `GeneralSettings` render is calling
`applyFilters('wedocs_pro_loaded', false)` repeatedly in multiple places,
including the Docs URL Structure label, badge, description, and gating branches.
Hoist this into a single `const isProLoaded = applyFilters('wedocs_pro_loaded',
false);` near the top of the component, then reuse `isProLoaded` throughout and
pass it into `renderUrlStructureDescription` so the pro-state logic is
centralized and the filter isn’t traversed redundantly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: aecc99e2-d42b-4aca-a6b6-20fb80d21463
📒 Files selected for processing (3)
src/components/ProPreviews/AiImageAnalysisPreview.jssrc/components/ProPreviews/SocialShareSettings.jssrc/components/Settings/GeneralSettings.js
Pro-locked settings in the free plugin rendered as if active (full-colour label, live-looking controls), which was confusing next to real settings.
All gated by
wedocs_pro_loaded— styling reverts to normal when Pro is active.Summary by CodeRabbit