mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-21 00:21:49 +00:00
fix(ui): gate MCP live connections tab to proxy admin tier roles
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
a9ab7392ae
commit
313093a8a0
3 changed files with 23 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { isAdminRole } from "@/utils/roles";
|
||||
import { isAdminRole, isProxyAdminTierRole } from "@/utils/roles";
|
||||
import { CircleHelp, Search } from "lucide-react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
|
@ -561,7 +561,7 @@ const MCPServers: React.FC<MCPServerProps> = ({ accessToken, userRole, userID })
|
|||
Submitted MCPs
|
||||
</TabsTrigger>
|
||||
)}
|
||||
{isAdminRole(userRole) && (
|
||||
{isProxyAdminTierRole(userRole) && (
|
||||
<TabsTrigger value="connections" className="flex-none rounded-none px-4 py-2">
|
||||
Live Connections
|
||||
</TabsTrigger>
|
||||
|
|
@ -753,7 +753,7 @@ const MCPServers: React.FC<MCPServerProps> = ({ accessToken, userRole, userID })
|
|||
<MCPSubmissionsTab accessToken={accessToken} />
|
||||
</TabsContent>
|
||||
)}
|
||||
{isAdminRole(userRole) && (
|
||||
{isProxyAdminTierRole(userRole) && (
|
||||
<TabsContent value="connections">
|
||||
<MCPGatewaySessionsTab accessToken={accessToken} />
|
||||
</TabsContent>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import {
|
|||
isOrgAdminForAnyOrg,
|
||||
isOrgAdminSessionRole,
|
||||
isProxyAdminRole,
|
||||
isProxyAdminTierRole,
|
||||
isUserTeamAdminForAnyTeam,
|
||||
isUserTeamAdminForSingleTeam,
|
||||
isViewOnlySessionRole,
|
||||
|
|
@ -58,6 +59,22 @@ describe("roles", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("isProxyAdminTierRole", () => {
|
||||
it("should return true for proxy admin and proxy admin viewer roles", () => {
|
||||
expect(isProxyAdminTierRole("proxy_admin")).toBe(true);
|
||||
expect(isProxyAdminTierRole("Admin")).toBe(true);
|
||||
expect(isProxyAdminTierRole("proxy_admin_viewer")).toBe(true);
|
||||
expect(isProxyAdminTierRole("Admin Viewer")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false for org admin and non-admin roles", () => {
|
||||
expect(isProxyAdminTierRole("org_admin")).toBe(false);
|
||||
expect(isProxyAdminTierRole("Internal User")).toBe(false);
|
||||
expect(isProxyAdminTierRole("Internal Viewer")).toBe(false);
|
||||
expect(isProxyAdminTierRole("")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isUserTeamAdminForSingleTeam", () => {
|
||||
it("should return true when user is team admin", () => {
|
||||
const members_with_roles = [
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ export const isProxyAdminRole = (role: string): boolean => {
|
|||
return role === "proxy_admin" || role === "Admin";
|
||||
};
|
||||
|
||||
export const proxyAdminTierRoles = ["Admin", "Admin Viewer", "proxy_admin", "proxy_admin_viewer"];
|
||||
export const isProxyAdminTierRole = (role: string): boolean => proxyAdminTierRoles.includes(role);
|
||||
|
||||
export const isUserTeamAdminForAnyTeam = (teams: Team[] | null, userID: string): boolean => {
|
||||
if (teams == null) {
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue