UI Fixes p2 (#8502)

* refactor(admin.tsx): cleanup add new admin flow

removes buggy flow. Ensures just 1 simple way to add users / update roles.

* fix(user_search_modal.tsx): ensure 'add member' button is always visible

* fix(edit_membership.tsx): ensure 'save changes' button always visible

* fix(internal_user_endpoints.py): ensure user in org can be deleted

Fixes issue where user couldn't be deleted if they were a member of an org

* fix: fix linting error
This commit is contained in:
Krish Dholakia 2025-02-12 22:51:54 -08:00 committed by GitHub
parent cc98d37c24
commit 1598a2636e
4 changed files with 8 additions and 112 deletions

View file

@ -885,6 +885,11 @@ async def delete_user(
where={"user_id": {"in": data.user_ids}}
)
## DELETE ASSOCIATED ORGANIZATION MEMBERSHIPS
await prisma_client.db.litellm_organizationmembership.delete_many(
where={"user_id": {"in": data.user_ids}}
)
## DELETE USERS
deleted_users = await prisma_client.db.litellm_usertable.delete_many(
where={"user_id": {"in": data.user_ids}}

View file

@ -496,116 +496,7 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
return (
<div className="w-full m-2 mt-2 p-8">
<Title level={4}>Admin Access </Title>
<Paragraph>
{showSSOBanner && (
<a href="https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access">
Requires SSO Setup
</a>
)}
<br />
<b>Proxy Admin: </b> Can create keys, teams, users, add models, etc.{" "}
<br />
<b>Proxy Admin Viewer: </b>Can just view spend. They cannot create keys,
teams or grant users access to new models.{" "}
</Paragraph>
<Grid numItems={1} className="gap-2 p-2 w-full">
<Col numColSpan={1}>
<Card className="w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]">
<Table>
<TableHead>
<TableRow>
<TableHeaderCell>Member Name</TableHeaderCell>
<TableHeaderCell>Role</TableHeaderCell>
</TableRow>
</TableHead>
<TableBody>
{admins
? admins.map((member: any, index: number) => (
<TableRow key={index}>
<TableCell>
{member["user_email"]
? member["user_email"]
: member["user_id"]
? member["user_id"]
: null}
</TableCell>
<TableCell>
{" "}
{possibleUIRoles?.[member?.user_role]?.ui_label ||
"-"}
</TableCell>
<TableCell>
<Icon
icon={PencilAltIcon}
size="sm"
onClick={() => setIsUpdateModalModalVisible(true)}
/>
<Modal
title="Update role"
visible={isUpdateMemberModalVisible}
width={800}
footer={null}
onOk={handleMemberUpdateOk}
onCancel={handleMemberUpdateCancel}
>
{modifyMemberForm(
handleMemberUpdate,
member["user_role"],
member["user_id"]
)}
</Modal>
</TableCell>
</TableRow>
))
: null}
</TableBody>
</Table>
</Card>
</Col>
<Col numColSpan={1}>
<div className="flex justify-start">
<Button
className="mr-4 mb-5"
onClick={() => setIsAddAdminModalVisible(true)}
>
+ Add admin
</Button>
<Modal
title="Add admin"
visible={isAddAdminModalVisible}
width={800}
footer={null}
onOk={handleAdminOk}
onCancel={handleAdminCancel}
>
{addMemberForm(handleAdminCreate)}
</Modal>
<OnboardingModal
isInvitationLinkModalVisible={isInvitationLinkModalVisible}
setIsInvitationLinkModalVisible={setIsInvitationLinkModalVisible}
baseUrl={baseUrl}
invitationLinkData={invitationLinkData}
/>
<Button
className="mb-5"
onClick={() => setIsAddMemberModalVisible(true)}
>
+ Add viewer
</Button>
<Modal
title="Add viewer"
visible={isAddMemberModalVisible}
width={800}
footer={null}
onOk={handleMemberOk}
onCancel={handleMemberCancel}
>
{addMemberForm(handleMemberCreate)}
</Modal>
</div>
</Col>
</Grid>
<Paragraph>Go to &apos;Internal Users&apos; page to add other admins.</Paragraph>
<Grid >
<Card>
<Title level={4}> Security Settings</Title>

View file

@ -163,7 +163,7 @@ const UserSearchModal: React.FC<UserSearchModalProps> = ({
</Form.Item>
<div className="text-right mt-4">
<Button type="primary" htmlType="submit">
<Button type="default" htmlType="submit">
Add Member
</Button>
</div>

View file

@ -129,7 +129,7 @@ const TeamMemberModal: React.FC<TeamMemberModalProps> = ({
Cancel
</AntButton>
<AntButton
type="primary"
type="default"
htmlType="submit"
>
{mode === 'add' ? 'Add Member' : 'Save Changes'}