Skip to content

Show Pro-only General/AI settings as disabled#329

Merged
iftakharul-islam merged 1 commit into
developfrom
improve/pro-settings-disabled-state
Jul 16, 2026
Merged

Show Pro-only General/AI settings as disabled#329
iftakharul-islam merged 1 commit into
developfrom
improve/pro-settings-disabled-state

Conversation

@anik-fahmid

@anik-fahmid anik-fahmid commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Pro-locked settings in the free plugin rendered as if active (full-colour label, live-looking controls), which was confusing next to real settings.

  • Docs URL Structure — mute the label, dropdown (removed an overlay/stacking bug) and the description; drop the PRO badge; condense the free help text to one line.
  • Enable image analysis — mute the label, toggle text and notes; drop the PRO badge.
  • Enable Social Share — drop the redundant PRO badge.

All gated by wedocs_pro_loaded — styling reverts to normal when Pro is active.

Summary by CodeRabbit

  • Style
    • Updated several settings screens with lighter gray text and cleaner spacing for a more consistent look.
    • Removed a few visible “PRO”/badge labels from certain options.
    • Refined the URL structure help text to show clearer messaging depending on the available product version.

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.
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This 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.

Changes

UI Styling and Badge Cleanup

Layer / File(s) Summary
AI image analysis preview styling and badge removal
src/components/ProPreviews/AiImageAnalysisPreview.js
Label, "Disable" text, and description paragraph switch to lighter gray styling; the Badge element after the "Enable image analysis" label is removed.
Social share PRO badge removal
src/components/ProPreviews/SocialShareSettings.js
Removes the "PRO" badge span next to SwitcherComponent, condensing the container JSX.
Docs URL Structure conditional styling
src/components/Settings/GeneralSettings.js
Code elements switch from indigo to gray styling; section label color and description content/styling now conditionally depend on the wedocs_pro_loaded filter.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: Needs Review

Suggested reviewers: iftakharul-islam

Poem

A hop, a skip, a shade of gray,
The PRO badges hopped away,
Docs URLs now softly gleam,
Pro or not, a cleaner theme,
This bunny thumps in review delight! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: Pro-only General/AI settings are styled to appear disabled in the free plugin.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch improve/pro-settings-disabled-state

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Dead code: non-pro branch of renderUrlStructureDescription is unreachable.

renderUrlStructureDescription() is only called at Line 189, inside the applyFilters('wedocs_pro_loaded', false) ? ... : ... branch that already requires isProLoaded to be true (Line 187). Since the function itself re-checks isProLoaded (Line 33/38), its else branch (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 renderUrlStructureDescription to 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 win

Label 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. Unlike AiImageAnalysisPreview (label muted to text-gray-400) and the "Docs URL Structure" label in GeneralSettings.js (conditionally muted via wedocs_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 value

Consolidate 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 into renderUrlStructureDescription) 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

📥 Commits

Reviewing files that changed from the base of the PR and between dd786d1 and e92f057.

📒 Files selected for processing (3)
  • src/components/ProPreviews/AiImageAnalysisPreview.js
  • src/components/ProPreviews/SocialShareSettings.js
  • src/components/Settings/GeneralSettings.js

@iftakharul-islam
iftakharul-islam merged commit 03f3b9c into develop Jul 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants