forked from phoenix/litellm-mirror
(feat) ui - conditionally show form based on userRole
This commit is contained in:
parent
59790c6cef
commit
6de6774509
2 changed files with 54 additions and 37 deletions
|
@ -11,6 +11,7 @@ const { Option } = Select;
|
|||
|
||||
interface CreateKeyProps {
|
||||
userID: string;
|
||||
userRole: string;
|
||||
accessToken: string;
|
||||
data: any[] | null;
|
||||
setData: React.Dispatch<React.SetStateAction<any[] | null>>;
|
||||
|
@ -18,6 +19,7 @@ interface CreateKeyProps {
|
|||
|
||||
const CreateKey: React.FC<CreateKeyProps> = ({
|
||||
userID,
|
||||
userRole,
|
||||
accessToken,
|
||||
data,
|
||||
setData,
|
||||
|
@ -81,7 +83,22 @@ const CreateKey: React.FC<CreateKeyProps> = ({
|
|||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="Team ID"
|
||||
name="team_id"
|
||||
>
|
||||
<Input placeholder="ai_team" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="Description"
|
||||
name="description"
|
||||
>
|
||||
<Input placeholder="ai_team" />
|
||||
</Form.Item>
|
||||
|
||||
{userRole === 'App Owner' || userRole === 'Admin' ? (
|
||||
<>
|
||||
<Form.Item
|
||||
label="Models (Comma Separated). Eg: gpt-3.5-turbo,gpt-4"
|
||||
name="models"
|
||||
|
@ -102,18 +119,14 @@ const CreateKey: React.FC<CreateKeyProps> = ({
|
|||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="Team ID"
|
||||
name="team_id"
|
||||
>
|
||||
<Input placeholder="ai_team" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="Metadata"
|
||||
name="metadata"
|
||||
>
|
||||
<Input.TextArea rows={4} placeholder="Enter metadata as JSON" />
|
||||
</Form.Item>
|
||||
</>
|
||||
) : null}
|
||||
<div style={{ textAlign: 'right', marginTop: '10px' }}>
|
||||
<Button2 htmlType="submit">
|
||||
Create Key
|
||||
|
|
|
@ -31,6 +31,8 @@ const UserDashboard = () => {
|
|||
switch (userRole.toLowerCase()) {
|
||||
case "app_owner":
|
||||
return "App Owner";
|
||||
case "demo_app_owner":
|
||||
return "AppOwner";
|
||||
case "admin":
|
||||
return "Admin";
|
||||
case "app_user":
|
||||
|
@ -104,12 +106,14 @@ const UserDashboard = () => {
|
|||
<Col numColSpan={1}>
|
||||
<ViewKeyTable
|
||||
userID={userID}
|
||||
userRole={userRole}
|
||||
accessToken={accessToken}
|
||||
data={data}
|
||||
setData={setData}
|
||||
/>
|
||||
<CreateKey
|
||||
userID={userID}
|
||||
userRole={userRole}
|
||||
accessToken={accessToken}
|
||||
data={data}
|
||||
setData={setData}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue