Invite User Searchable Team Select (#16454)

This commit is contained in:
yuneng-jiang 2025-11-10 18:38:23 -08:00 • committed by GitHub
parent be3c09e6d5
commit 8f1f5825aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 27 deletions

View file

@ -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();
});
});

View file

@ -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">