mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
Litellm dev 01 10 2025 p2 (#7679)
* test(test_basic_python_version.py): assert all optional dependencies are marked as extras on poetry Fixes https://github.com/BerriAI/litellm/issues/7677 * docs(secret.md): clarify 'read_and_write' secret manager usage on aws * docs(secret.md): fix doc * build(ui/teams.tsx): add edit/delete button for updating user / team membership on ui allows updating user role to admin on ui * build(ui/teams.tsx): display edit member component on ui, when edit button on member clicked * feat(team_endpoints.py): support updating team member role to admin via api endpoints allows team member to become admin post-add * build(ui/user_dashboard.tsx): if team admin - show all team keys Fixes https://github.com/BerriAI/litellm/issues/7650 * test(config.yml): add tomli to ci/cd * test: don't call python_basic_testing in local testing (covered by python 3.13 testing)
This commit is contained in:
parent
49d74748b0
commit
c4780479a9
15 changed files with 425 additions and 67 deletions
|
@ -131,6 +131,57 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({
|
|||
|
||||
const [knownTeamIDs, setKnownTeamIDs] = useState(initialKnownTeamIDs);
|
||||
|
||||
// Function to check if user is admin of a team
|
||||
const isUserTeamAdmin = (team: any) => {
|
||||
if (!team.members_with_roles) return false;
|
||||
return team.members_with_roles.some(
|
||||
(member: any) => member.role === "admin" && member.user_id === userID
|
||||
);
|
||||
};
|
||||
|
||||
// Combine all keys that user should have access to
|
||||
const all_keys_to_display = React.useMemo(() => {
|
||||
let allKeys: any[] = [];
|
||||
|
||||
// If no teams, return personal keys
|
||||
if (!teams || teams.length === 0) {
|
||||
return data;
|
||||
}
|
||||
|
||||
teams.forEach(team => {
|
||||
// For default team or when user is not admin, use personal keys (data)
|
||||
if (team.team_id === "default-team" || !isUserTeamAdmin(team)) {
|
||||
if (selectedTeam && selectedTeam.team_id === team.team_id) {
|
||||
allKeys = [...allKeys, ...data.filter(key => key.team_id === team.team_id)];
|
||||
}
|
||||
}
|
||||
// For teams where user is admin, use team keys
|
||||
else if (isUserTeamAdmin(team)) {
|
||||
if (selectedTeam && selectedTeam.team_id === team.team_id) {
|
||||
allKeys = [...allKeys, ...(team.keys || [])];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// If no team is selected, show all accessible keys
|
||||
if (!selectedTeam) {
|
||||
const personalKeys = data.filter(key => !key.team_id || key.team_id === "default-team");
|
||||
const adminTeamKeys = teams
|
||||
.filter(team => isUserTeamAdmin(team))
|
||||
.flatMap(team => team.keys || []);
|
||||
allKeys = [...personalKeys, ...adminTeamKeys];
|
||||
}
|
||||
|
||||
// Filter out litellm-dashboard keys
|
||||
allKeys = allKeys.filter(key => key.team_id !== "litellm-dashboard");
|
||||
|
||||
// Remove duplicates based on token
|
||||
const uniqueKeys = Array.from(
|
||||
new Map(allKeys.map(key => [key.token, key])).values()
|
||||
);
|
||||
|
||||
return uniqueKeys;
|
||||
}, [data, teams, selectedTeam, userID]);
|
||||
|
||||
useEffect(() => {
|
||||
const calculateNewExpiryTime = (duration: string | undefined) => {
|
||||
|
@ -858,7 +909,7 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({
|
|||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{data.map((item) => {
|
||||
{all_keys_to_display.map((item) => {
|
||||
console.log(item);
|
||||
// skip item if item.team_id == "litellm-dashboard"
|
||||
if (item.team_id === "litellm-dashboard") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue