[Feature] UI - User Dropdown: Gate 'Hide All Prompts' to enterprise users#21842
[Feature] UI - User Dropdown: Gate 'Hide All Prompts' to enterprise users#21842yuneng-jiang wants to merge 3 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryGates the "Hide All Prompts" toggle in the user dropdown to enterprise (premium) users only. Enterprise users now have prompts hidden by default (opt-out), while non-enterprise users always see prompts with the toggle disabled. Includes a minor bug fix in
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/app/(dashboard)/hooks/useDisableShowPrompts.ts | Added enterprise gating: non-premium users always return false; premium users default to true (prompts hidden) when no stored preference exists. Added getServerSnapshot for SSR compatibility. |
| ui/litellm-dashboard/src/components/Navbar/UserDropdown/UserDropdown.tsx | Disabled "Hide All Prompts" switch for non-premium users with tooltip and Enterprise tag. Toggle now stores explicit "false" instead of removing the key. Minor formatting cleanup throughout. |
| ui/litellm-dashboard/src/app/(dashboard)/hooks/useDisableShowPrompts.test.ts | Tests reorganized into non-premium, premium, and loading state groups. Good coverage of default-on behavior, explicit toggle, and event listener scenarios. |
| ui/litellm-dashboard/src/components/Navbar/UserDropdown/UserDropdown.test.tsx | Toggle tests now set premiumUser: true for hide-prompts tests. Toggle-off assertion changed from removeLocalStorageItem to setLocalStorageItem with "false". |
| ui/litellm-dashboard/src/components/add_model/handle_add_auto_router_submit.tsx | Removed invalid second argument "success" from NotificationManager.fromBackend() call, and minor whitespace cleanup. |
| ui/litellm-dashboard/src/components/organization/organization_view.test.tsx | Removed test for "No members found" empty state which referenced text that doesn't exist in the component. Added unused userEvent import. |
| ui/litellm-dashboard/package.json | Added dev:webpack script for alternative webpack-based dev server. |
| ui/litellm-dashboard/package-lock.json | Lock file regeneration marking several packages as dev-only dependencies. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[useDisableShowPrompts hook called] --> B{premiumUser?}
B -->|null / false| C[Return false\nPrompts always shown]
B -->|true| D{localStorage\ndisableShowPrompts}
D -->|null / absent| E[Return true\nDefault: prompts hidden]
D -->|"true"| F[Return true\nPrompts hidden]
D -->|"false"| G[Return false\nUser opted to show]
H[UserDropdown Switch] --> I{premiumUser?}
I -->|false / null| J[Switch disabled\n+ Enterprise tag\n+ Info tooltip]
I -->|true| K[Switch enabled]
K -->|Toggle ON| L[setLocalStorageItem\ndisableShowPrompts = true]
K -->|Toggle OFF| M[setLocalStorageItem\ndisableShowPrompts = false]
Last reviewed commit: 118775b
| onChange={(checked) => { | ||
| if (checked) { | ||
| setLocalStorageItem("disableShowPrompts", "true"); | ||
| emitLocalStorageChange("disableShowPrompts"); | ||
| } else { | ||
| removeLocalStorageItem("disableShowPrompts"); | ||
| emitLocalStorageChange("disableShowPrompts"); | ||
| } | ||
| if (!premiumUser) return; | ||
| setLocalStorageItem("disableShowPrompts", checked ? "true" : "false"); |
There was a problem hiding this comment.
Redundant guard on disabled switch
The if (!premiumUser) return; check on line 130 is unnecessary since the switch is already disabled={!premiumUser} on line 128. The onChange handler will never fire for non-premium users when the switch is disabled by Ant Design. Consider removing the guard to reduce dead code.
| onChange={(checked) => { | |
| if (checked) { | |
| setLocalStorageItem("disableShowPrompts", "true"); | |
| emitLocalStorageChange("disableShowPrompts"); | |
| } else { | |
| removeLocalStorageItem("disableShowPrompts"); | |
| emitLocalStorageChange("disableShowPrompts"); | |
| } | |
| if (!premiumUser) return; | |
| setLocalStorageItem("disableShowPrompts", checked ? "true" : "false"); | |
| onChange={(checked) => { | |
| setLocalStorageItem("disableShowPrompts", checked ? "true" : "false"); | |
| emitLocalStorageChange("disableShowPrompts"); |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
ui/litellm-dashboard/src/components/organization/organization_view.test.tsx
Outdated
Show resolved
Hide resolved
…view.test.tsx Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Summary
The "Hide All Prompts" toggle in the user dropdown was accessible to all users but had no effect for non-enterprise users. This restricts the feature so that:
Changes
useDisableShowPrompts: Enterprise users now default totrue(prompts hidden) when no stored preference exists. Non-enterprise users always returnfalse.UserDropdown: The "Hide All Prompts" switch is disabled for non-enterprise users and shows an info icon tooltip and an Enterprise tag. The toggle handler now stores"false"explicitly (instead of removing the key) so the enterprise default-on logic is not accidentally re-triggered.Testing
useDisableShowPrompts.test.ts: Covers default-on for enterprise, always-off for non-enterprise, and toggling behavior.UserDropdown.test.tsx: Toggle tests now setpremiumUser: trueand assertsetLocalStorageItem("disableShowPrompts", "false")for the off case.organization_view.test.tsx: Empty state test now navigates to the Members tab before asserting.Type
🆕 New Feature
✅ Test