Create Team Model Dropdown fix

This commit is contained in:
yuneng-jiang 2025-12-11 10:16:42 -08:00
parent 917997cf79
commit 6e99faeced
4 changed files with 18 additions and 7 deletions

View file

@ -616,13 +616,13 @@ describe("OldTeams - Default Team Settings tab visibility", () => {
});
});
describe("OldTeams - all-proxy-models dropdown visibility", () => {
describe("OldTeams - models dropdown options", () => {
beforeEach(() => {
vi.clearAllMocks();
vi.mocked(fetchAvailableModelsForTeamOrKey).mockResolvedValue(["gpt-4", "gpt-3.5-turbo"]);
});
it("should not show all-proxy-models option when user has no access to it", async () => {
it("should not render all-proxy-models option in models select", async () => {
vi.mocked(fetchAvailableModelsForTeamOrKey).mockResolvedValue(["gpt-4", "gpt-3.5-turbo"]);
render(

View file

@ -1158,11 +1158,6 @@ const Teams: React.FC<TeamProps> = ({
name="models"
>
<Select2 mode="multiple" placeholder="Select models" style={{ width: "100%" }}>
{(isProxyAdminRole(userRole || "") || userModels.includes("all-proxy-models")) && (
<Select2.Option key="all-proxy-models" value="all-proxy-models">
All Proxy Models
</Select2.Option>
)}
<Select2.Option key="no-default-models" value="no-default-models">
No Default Models
</Select2.Option>

View file

@ -0,0 +1,13 @@
import { describe, expect, it } from "vitest";
import { getModelDisplayName } from "./fetch_available_models_team_key";
describe("getModelDisplayName", () => {
it("should return display label for all proxy models", () => {
expect(getModelDisplayName("all-proxy-models")).toBe("All Proxy Models");
});
it("should return provider-wide label for wildcard models", () => {
expect(getModelDisplayName("openai/*")).toBe("All openai models");
});
});

View file

@ -36,6 +36,9 @@ export const fetchAvailableModelsForTeamOrKey = async (
};
export const getModelDisplayName = (model: string) => {
if (model === "all-proxy-models") {
return "All Proxy Models";
}
if (model.endsWith("/*")) {
const provider = model.replace("/*", "");
return `All ${provider} models`;