mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
Invite User Searchable Team Select (#16454)
This commit is contained in:
parent
be3c09e6d5
commit
8f1f5825aa
2 changed files with 41 additions and 27 deletions
|
|
@ -0,0 +1,35 @@
|
|||
import React from "react";
|
||||
import { render } from "@testing-library/react";
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import Createuser from "./create_user_button";
|
||||
|
||||
vi.mock("./networking", () => ({
|
||||
userCreateCall: vi.fn(),
|
||||
modelAvailableCall: vi.fn().mockResolvedValue({ data: [] }),
|
||||
invitationCreateCall: vi.fn(),
|
||||
getProxyUISettings: vi.fn().mockResolvedValue({
|
||||
PROXY_BASE_URL: null,
|
||||
PROXY_LOGOUT_URL: null,
|
||||
DEFAULT_TEAM_DISABLED: false,
|
||||
SSO_ENABLED: false,
|
||||
}),
|
||||
getProxyBaseUrl: vi.fn().mockReturnValue("http://localhost"),
|
||||
}));
|
||||
|
||||
const createQueryClient = () =>
|
||||
new QueryClient({
|
||||
defaultOptions: { queries: { retry: false, gcTime: 0 } },
|
||||
});
|
||||
|
||||
describe("Create User Button", () => {
|
||||
it("should render the create user button", () => {
|
||||
const qc = createQueryClient();
|
||||
const { getByText } = render(
|
||||
<QueryClientProvider client={qc}>
|
||||
<Createuser userID="123" accessToken="123" teams={[]} possibleUIRoles={{}} isEmbedded />
|
||||
</QueryClientProvider>,
|
||||
);
|
||||
expect(getByText("Create User")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
@ -26,6 +26,7 @@ import { InfoCircleOutlined } from "@ant-design/icons";
|
|||
import { getModelDisplayName } from "./key_team_helpers/fetch_available_models_team_key";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import NotificationsManager from "./molecules/notifications_manager";
|
||||
import TeamDropdown from "./common_components/team_dropdown";
|
||||
|
||||
// Helper function to generate UUID compatible across all environments
|
||||
const generateUUID = (): string => {
|
||||
|
|
@ -201,19 +202,9 @@ const Createuser: React.FC<CreateuserProps> = ({
|
|||
))}
|
||||
</Select2>
|
||||
</Form.Item>
|
||||
<Form.Item label="Team ID" name="team_id">
|
||||
<Select placeholder="Select Team ID" style={{ width: "100%" }}>
|
||||
{teams ? (
|
||||
teams.map((team: any) => (
|
||||
<Option key={team.team_id} value={team.team_id}>
|
||||
{team.team_alias}
|
||||
</Option>
|
||||
))
|
||||
) : (
|
||||
<Option key="default" value={null}>
|
||||
Default Team
|
||||
</Option>
|
||||
)}
|
||||
<Form.Item label="Team" name="team_id">
|
||||
<Select placeholder="Select Team" style={{ width: "100%" }}>
|
||||
<TeamDropdown teams={teams} />
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
|
|
@ -275,24 +266,12 @@ const Createuser: React.FC<CreateuserProps> = ({
|
|||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="Team ID"
|
||||
label="Team"
|
||||
className="gap-2"
|
||||
name="team_id"
|
||||
help="If selected, user will be added as a 'user' role to the team."
|
||||
>
|
||||
<Select placeholder="Select Team ID" style={{ width: "100%" }}>
|
||||
{teams ? (
|
||||
teams.map((team: any) => (
|
||||
<Option key={team.team_id} value={team.team_id}>
|
||||
{team.team_alias}
|
||||
</Option>
|
||||
))
|
||||
) : (
|
||||
<Option key="default" value={null}>
|
||||
Default Team
|
||||
</Option>
|
||||
)}
|
||||
</Select>
|
||||
<TeamDropdown teams={teams} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="Metadata" name="metadata">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue