forked from phoenix/litellm-mirror
(ui) edit teams
This commit is contained in:
parent
0342cd3b6b
commit
4a6aa3ee61
1 changed files with 107 additions and 0 deletions
|
@ -51,6 +51,8 @@ const Team: React.FC<TeamProps> = ({
|
||||||
const [memberForm] = Form.useForm();
|
const [memberForm] = Form.useForm();
|
||||||
const { Title, Paragraph } = Typography;
|
const { Title, Paragraph } = Typography;
|
||||||
const [value, setValue] = useState("");
|
const [value, setValue] = useState("");
|
||||||
|
const [editModalVisible, setEditModalVisible] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
const [selectedTeam, setSelectedTeam] = useState<null | any>(
|
const [selectedTeam, setSelectedTeam] = useState<null | any>(
|
||||||
teams ? teams[0] : null
|
teams ? teams[0] : null
|
||||||
|
@ -61,6 +63,102 @@ const Team: React.FC<TeamProps> = ({
|
||||||
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||||
const [teamToDelete, setTeamToDelete] = useState<string | null>(null);
|
const [teamToDelete, setTeamToDelete] = useState<string | null>(null);
|
||||||
|
|
||||||
|
|
||||||
|
const EditTeamModal = ({ visible, onCancel, team, onSubmit }) => {
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
|
const handleOk = () => {
|
||||||
|
form
|
||||||
|
.validateFields()
|
||||||
|
.then((values) => {
|
||||||
|
onSubmit(team.team_id, values);
|
||||||
|
form.resetFields();
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Validation failed:", error);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
title="Edit Team"
|
||||||
|
visible={visible}
|
||||||
|
width={800}
|
||||||
|
footer={null}
|
||||||
|
onOk={handleOk}
|
||||||
|
onCancel={onCancel}
|
||||||
|
>
|
||||||
|
<Form
|
||||||
|
form={form}
|
||||||
|
initialValues={team} // Pass initial values here
|
||||||
|
labelCol={{ span: 8 }}
|
||||||
|
wrapperCol={{ span: 16 }}
|
||||||
|
labelAlign="left"
|
||||||
|
>
|
||||||
|
<>
|
||||||
|
<Form.Item
|
||||||
|
label="Team Name"
|
||||||
|
name="team_alias"
|
||||||
|
rules={[{ required: true, message: 'Please input a team name' }]}
|
||||||
|
>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item label="Models" name="models">
|
||||||
|
<Select2
|
||||||
|
mode="multiple"
|
||||||
|
placeholder="Select models"
|
||||||
|
style={{ width: "100%" }}
|
||||||
|
>
|
||||||
|
{userModels && userModels.map((model) => (
|
||||||
|
<Select2.Option key={model} value={model}>
|
||||||
|
{model}
|
||||||
|
</Select2.Option>
|
||||||
|
))}
|
||||||
|
</Select2>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item label="Max Budget (USD)" name="max_budget">
|
||||||
|
<InputNumber step={0.01} precision={2} width={200} />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
label="Tokens per minute Limit (TPM)"
|
||||||
|
name="tpm_limit"
|
||||||
|
>
|
||||||
|
<InputNumber step={1} width={400} />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
label="Requests per minute Limit (RPM)"
|
||||||
|
name="rpm_limit"
|
||||||
|
>
|
||||||
|
<InputNumber step={1} width={400} />
|
||||||
|
</Form.Item>
|
||||||
|
</>
|
||||||
|
<div style={{ textAlign: "right", marginTop: "10px" }}>
|
||||||
|
<Button2 htmlType="submit">Edit Team</Button2>
|
||||||
|
</div>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEditClick = (team: any) => {
|
||||||
|
setSelectedTeam(team);
|
||||||
|
setEditModalVisible(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEditCancel = () => {
|
||||||
|
setEditModalVisible(false);
|
||||||
|
setSelectedTeam(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEditSubmit = (teamId: string, values) => {
|
||||||
|
// Call API to update team with teamId and values
|
||||||
|
// Handle success or failure accordingly
|
||||||
|
console.log("Editing team:", teamId, "with values:", values);
|
||||||
|
message.success("Team updated successfully");
|
||||||
|
setEditModalVisible(false);
|
||||||
|
setSelectedTeam(null);
|
||||||
|
};
|
||||||
|
|
||||||
const handleOk = () => {
|
const handleOk = () => {
|
||||||
setIsTeamModalVisible(false);
|
setIsTeamModalVisible(false);
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
|
@ -261,6 +359,7 @@ const Team: React.FC<TeamProps> = ({
|
||||||
<Icon
|
<Icon
|
||||||
icon={PencilAltIcon}
|
icon={PencilAltIcon}
|
||||||
size="sm"
|
size="sm"
|
||||||
|
onClick={() => handleEditClick(team)}
|
||||||
/>
|
/>
|
||||||
<Icon
|
<Icon
|
||||||
onClick={() => handleDelete(team.team_id)}
|
onClick={() => handleDelete(team.team_id)}
|
||||||
|
@ -449,6 +548,14 @@ const Team: React.FC<TeamProps> = ({
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</Card>
|
</Card>
|
||||||
|
{selectedTeam && (
|
||||||
|
<EditTeamModal
|
||||||
|
visible={editModalVisible}
|
||||||
|
onCancel={handleEditCancel}
|
||||||
|
team={selectedTeam}
|
||||||
|
onSubmit={handleEditSubmit}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
<Col numColSpan={1}>
|
<Col numColSpan={1}>
|
||||||
<Button
|
<Button
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue