From 3e97c0d5d62f80a18754612fd7e90d2b33de2b55 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Sat, 14 Feb 2026 16:33:35 -0800 Subject: [PATCH] temp commit for merge --- .../common_components/AccessGroupSelector.tsx | 112 ++++++++++++++++++ .../organisms/create_key_button.tsx | 18 +++ 2 files changed, 130 insertions(+) create mode 100644 ui/litellm-dashboard/src/components/common_components/AccessGroupSelector.tsx diff --git a/ui/litellm-dashboard/src/components/common_components/AccessGroupSelector.tsx b/ui/litellm-dashboard/src/components/common_components/AccessGroupSelector.tsx new file mode 100644 index 00000000000..392587d910a --- /dev/null +++ b/ui/litellm-dashboard/src/components/common_components/AccessGroupSelector.tsx @@ -0,0 +1,112 @@ +import React from "react"; +import { Select, Skeleton } from "antd"; +import { TeamOutlined } from "@ant-design/icons"; +import { Text } from "@tremor/react"; +import { + useAccessGroups, + AccessGroupResponse, +} from "@/app/(dashboard)/hooks/accessGroups/useAccessGroups"; + +export interface AccessGroupSelectorProps { + value?: string[]; + onChange?: (value: string[]) => void; + placeholder?: string; + disabled?: boolean; + style?: React.CSSProperties; + className?: string; + showLabel?: boolean; + labelText?: string; + /** Allow clearing the selection */ + allowClear?: boolean; +} + +/** + * Reusable multi-select selector for access groups. + * + * - Displays the **access_group_name** in the dropdown. + * - Returns an array of **access_group_id** values. + * - Always multi-select since users can assign multiple access groups. + * - Integrates with Ant Design `` out of the box via `value` / `onChange`. + */ +const AccessGroupSelector: React.FC = ({ + value, + onChange, + placeholder = "Select access groups", + disabled = false, + style, + className, + showLabel = false, + labelText = "Access Group", + allowClear = true, +}) => { + const { data: accessGroups, isLoading, isError } = useAccessGroups(); + + // ── Loading skeleton ───────────────────────────────────────────────────── + if (isLoading) { + return ( +
+ {showLabel && ( + + {labelText} + + )} + +
+ ); + } + + // ── Build options ──────────────────────────────────────────────────────── + const options = (accessGroups ?? []).map((group: AccessGroupResponse) => ({ + label: ( + + {group.access_group_name}{" "} + ({group.access_group_id}) + + ), + value: group.access_group_id, + selectedLabel: group.access_group_name, + searchText: `${group.access_group_name} ${group.access_group_id}`, + })); + + // ── Render ─────────────────────────────────────────────────────────────── + return ( +
+ {showLabel && ( + + {labelText} + + )} +