mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-03 01:38:46 +00:00
* fix(ui): show Projects nav to team and org admins Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(ui): satisfy frontend lint budget Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * style(ui): format leftnav regression tests Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(projects): let org admins see projects of every team in their orgs /project/list and /project/info only knew proxy admins and team members, so an org admin saw projects only for teams they had personally joined. Both now use the same team access check as /team/info. * fix(ui): one shared Projects access rule for nav, data and actions The Projects query skipped global org_admin users, the page-visibility picker could never offer Projects, and New/Edit showed to users the backend would reject. Nav and queries now share one rule, Projects is selectable in the allowlist, New/Edit follow team_admin_editable_team_fields, and the project modal only lists teams the user administers. * fix(projects): record IN-list bounds for project visibility filters Both filters are bounded by one caller's team memberships and admin orgs. Also cover a project whose team was deleted. --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: ryan-crabbe-berri <ryan@berri.ai>
73 lines
2.4 KiB
TypeScript
73 lines
2.4 KiB
TypeScript
/**
|
|
* Utility functions for working with navigation pages
|
|
*/
|
|
|
|
import { labelText, menuGroups } from "./leftnav";
|
|
import { pageDescriptions, PageMetadata } from "./page_metadata";
|
|
import { internalUserRoles } from "@/utils/roles";
|
|
|
|
/**
|
|
* Check if a page is accessible to internal users
|
|
* A page is accessible if:
|
|
* 1. It has no role restrictions, OR
|
|
* 2. Its roles include at least one internal user role
|
|
*/
|
|
const isPageAccessibleToInternalUsers = (pageRoles?: string[]): boolean => {
|
|
if (!pageRoles || pageRoles.length === 0) {
|
|
return true; // No role restrictions
|
|
}
|
|
|
|
// Check if any of the page's roles match internal user roles
|
|
return pageRoles.some((role) => internalUserRoles.includes(role));
|
|
};
|
|
|
|
/**
|
|
* Get all available pages from the navigation menu configuration
|
|
* Used by UI Settings to display available pages for visibility control
|
|
*
|
|
* IMPORTANT: Only returns pages that internal users can access.
|
|
* Pages restricted to admin-only roles are excluded because internal users
|
|
* cannot see them regardless of the UI visibility setting.
|
|
*/
|
|
export const getAvailablePages = (): PageMetadata[] => {
|
|
const pages: PageMetadata[] = [];
|
|
|
|
menuGroups.forEach((group) => {
|
|
group.items.forEach((item) => {
|
|
// Add top-level items (skip parent containers like 'tools', 'experimental', 'settings')
|
|
// Also skip items that internal users cannot access
|
|
if (
|
|
item.page &&
|
|
item.page !== "tools" &&
|
|
item.page !== "experimental" &&
|
|
item.page !== "settings" &&
|
|
isPageAccessibleToInternalUsers(item.roles)
|
|
) {
|
|
pages.push({
|
|
page: item.page,
|
|
label: labelText(item),
|
|
group: group.groupLabel,
|
|
description: pageDescriptions[item.page] || "No description available",
|
|
});
|
|
}
|
|
|
|
// Add children items (also skip those internal users cannot access)
|
|
if (item.children) {
|
|
const parentLabel = labelText(item);
|
|
item.children.forEach((child) => {
|
|
// Include if internal users can access
|
|
if (isPageAccessibleToInternalUsers(child.roles)) {
|
|
pages.push({
|
|
page: child.page,
|
|
label: labelText(child),
|
|
group: `${group.groupLabel} > ${parentLabel}`,
|
|
description: pageDescriptions[child.page] || "No description available",
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
return pages;
|
|
};
|