mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
Create Team Form: Disallow selecting 'All Proxy Models' when organization is selected
This commit is contained in:
parent
b82af5b826
commit
36492c5a97
1 changed files with 19 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect, useMemo } from "react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Typography } from "antd";
|
import { Typography } from "antd";
|
||||||
import { teamDeleteCall, teamUpdateCall, teamInfoCall, Organization, DEFAULT_ORGANIZATION } from "./networking";
|
import { teamDeleteCall, teamUpdateCall, teamInfoCall, Organization, DEFAULT_ORGANIZATION } from "./networking";
|
||||||
|
@ -118,7 +118,6 @@ const Teams: React.FC<TeamProps> = ({
|
||||||
}) => {
|
}) => {
|
||||||
const [lastRefreshed, setLastRefreshed] = useState("");
|
const [lastRefreshed, setLastRefreshed] = useState("");
|
||||||
const [currentOrg, setCurrentOrg] = useState<Organization | null>(null);
|
const [currentOrg, setCurrentOrg] = useState<Organization | null>(null);
|
||||||
const [currentOrgForCreateTeam, setCurrentOrgForCreateTeam] = useState<Organization | null>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log(`inside useeffect - ${lastRefreshed}`)
|
console.log(`inside useeffect - ${lastRefreshed}`)
|
||||||
|
@ -149,7 +148,11 @@ const Teams: React.FC<TeamProps> = ({
|
||||||
const [teamToDelete, setTeamToDelete] = useState<string | null>(null);
|
const [teamToDelete, setTeamToDelete] = useState<string | null>(null);
|
||||||
const [modelsToPick, setModelsToPick] = useState<string[]>([]);
|
const [modelsToPick, setModelsToPick] = useState<string[]>([]);
|
||||||
|
|
||||||
|
const selectedOrganizationId = Form.useWatch('organization_id', form)
|
||||||
|
|
||||||
|
const currentOrgForCreateTeam = useMemo<Organization | null>(() => {
|
||||||
|
return organizations?.find((org) => org.organization_id === selectedOrganizationId) || null
|
||||||
|
}, [selectedOrganizationId])
|
||||||
|
|
||||||
const [perTeamInfo, setPerTeamInfo] = useState<Record<string, any>>({});
|
const [perTeamInfo, setPerTeamInfo] = useState<Record<string, any>>({});
|
||||||
|
|
||||||
|
@ -665,7 +668,12 @@ const Teams: React.FC<TeamProps> = ({
|
||||||
placeholder="Search or select an Organization"
|
placeholder="Search or select an Organization"
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
form.setFieldValue('organization_id', value);
|
form.setFieldValue('organization_id', value);
|
||||||
setCurrentOrgForCreateTeam(organizations?.find((org) => org.organization_id === value) || null);
|
if (value) {
|
||||||
|
const selectedModels = form.getFieldValue('models') as (string[] | undefined)
|
||||||
|
if (selectedModels) {
|
||||||
|
form.setFieldValue('models', selectedModels.filter(m => m !== 'all-proxy-models'))
|
||||||
|
}
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
filterOption={(input, option) => {
|
filterOption={(input, option) => {
|
||||||
if (!option) return false;
|
if (!option) return false;
|
||||||
|
@ -695,12 +703,14 @@ const Teams: React.FC<TeamProps> = ({
|
||||||
placeholder="Select models"
|
placeholder="Select models"
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
>
|
>
|
||||||
<Select2.Option
|
{selectedOrganizationId ? null : (
|
||||||
key="all-proxy-models"
|
<Select2.Option
|
||||||
value="all-proxy-models"
|
key="all-proxy-models"
|
||||||
>
|
value="all-proxy-models"
|
||||||
All Proxy Models
|
>
|
||||||
</Select2.Option>
|
All Proxy Models
|
||||||
|
</Select2.Option>
|
||||||
|
)}
|
||||||
{modelsToPick.map((model) => (
|
{modelsToPick.map((model) => (
|
||||||
<Select2.Option key={model} value={model}>
|
<Select2.Option key={model} value={model}>
|
||||||
{getModelDisplayName(model)}
|
{getModelDisplayName(model)}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue