Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/litellm-dashboard/e2e_tests/fixtures/migratedPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const MIGRATED_E2E_PAGES: Record<string, string> = {
new_usage: "usage",
agents: "agents",
"router-settings": "router-settings",
users: "users",
};

export const MIGRATED_E2E_SEGMENTS: string[] = [...new Set(Object.values(MIGRATED_E2E_PAGES))];
11 changes: 0 additions & 11 deletions ui/litellm-dashboard/src/app/(dashboard)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import { SurveyPrompt, SurveyModal, ClaudeCodePrompt, ClaudeCodeModal } from "@/components/survey";
import Usage from "@/components/usage";
import UserDashboard from "@/components/user_dashboard";
import ViewUserDashboard from "@/components/view_users";
import { useAuth } from "@/contexts/AuthContext";
import {
buildLoginUrlWithReturn,
Expand All @@ -31,13 +30,13 @@
useAuth();

const [teams, setTeams] = useState<Team[] | null>(null);
const [keys, setKeys] = useState<null | any[]>([]);

Check warning on line 33 in ui/litellm-dashboard/src/app/(dashboard)/page.tsx

View workflow job for this annotation

GitHub Actions / frontend-lint

Unexpected any. Specify a different type
const [organizations, setOrganizations] = useState<Organization[]>([]);
const [userModels, setUserModels] = useState<string[]>([]);

const router = useRouter();
const searchParams = useSearchParams()!;
const [modelData, setModelData] = useState<any>({ data: [] });

Check warning on line 39 in ui/litellm-dashboard/src/app/(dashboard)/page.tsx

View workflow job for this annotation

GitHub Actions / frontend-lint

Unexpected any. Specify a different type
const [createClicked, setCreateClicked] = useState<boolean>(false);

const { data: uiSettingsData, isLoading: uiSettingsLoading } = useUISettings();
Expand Down Expand Up @@ -109,7 +108,7 @@
// Track if we've already attempted a return URL redirect to prevent race conditions
const hasAttemptedReturnRedirectRef = useRef(false);

const addKey = (data: any) => {

Check warning on line 111 in ui/litellm-dashboard/src/app/(dashboard)/page.tsx

View workflow job for this annotation

GitHub Actions / frontend-lint

Unexpected any. Specify a different type
setKeys((prevData) => (prevData ? [...prevData, data] : [data]));
setCreateClicked(() => !createClicked);
};
Expand Down Expand Up @@ -323,16 +322,6 @@
premiumUser={premiumUser}
teams={teams}
/>
) : page == "users" ? (
<ViewUserDashboard
userID={userID}
userRole={userRole}
token={token}
keys={keys}
teams={teams}
accessToken={accessToken}
setKeys={setKeys}
/>
) : page == "teams" ? (
<OldTeams
teams={teams}
Expand Down
19 changes: 19 additions & 0 deletions ui/litellm-dashboard/src/app/(dashboard)/users/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use client";

import ViewUserDashboard from "@/components/view_users";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import { useTeams } from "@/app/(dashboard)/hooks/teams/useTeams";

export default function UsersPage() {
const { accessToken, token, userRole, userId } = useAuthorized();
const { data: teams } = useTeams();
return (
<ViewUserDashboard
userID={userId}
userRole={userRole}
token={token}
teams={teams ?? null}
accessToken={accessToken}
/>
);
}
2 changes: 0 additions & 2 deletions ui/litellm-dashboard/src/components/view_users.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ describe("ViewUserDashboard", () => {
const defaultProps = {
accessToken: "test-token",
token: "test-token",
keys: null,
userRole: "Admin",
userID: "admin-user-id",
teams: [],
setKeys: vi.fn(),
};

beforeEach(() => {
Expand Down
2 changes: 0 additions & 2 deletions ui/litellm-dashboard/src/components/view_users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@
interface ViewUserDashboardProps {
accessToken: string | null;
token: string | null;
keys: any[] | null;
userRole: string | null;
userID: string | null;
teams: any[] | null;

Check warning on line 39 in ui/litellm-dashboard/src/components/view_users.tsx

View workflow job for this annotation

GitHub Actions / frontend-lint

Unexpected any. Specify a different type
setKeys: React.Dispatch<React.SetStateAction<object[] | null>>;
orgAdminOrgIds?: Array<{ organization_id: string; organization_alias: string }> | null;
}

Expand Down Expand Up @@ -77,7 +75,7 @@
userID,
teams,
orgAdminOrgIds,
}) => {

Check warning on line 78 in ui/litellm-dashboard/src/components/view_users.tsx

View workflow job for this annotation

GitHub Actions / frontend-lint

Arrow function has a complexity of 37. Maximum allowed is 20
const isProxyAdmin = userRole ? isProxyAdminRole(userRole) : false;
const queryClient = useQueryClient();
const [currentPage, setCurrentPage] = useState(1);
Expand Down Expand Up @@ -194,7 +192,7 @@
setEditModalVisible(false);
};

const handleEditSubmit = async (editedUser: any) => {

Check warning on line 195 in ui/litellm-dashboard/src/components/view_users.tsx

View workflow job for this annotation

GitHub Actions / frontend-lint

Unexpected any. Specify a different type
console.log("inside handleEditSubmit:", editedUser);

if (!accessToken || !token || !userRole || !userID) {
Expand Down
7 changes: 7 additions & 0 deletions ui/litellm-dashboard/src/utils/migratedPages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ describe("migratedHref / legacyPageHref", () => {
expect(MIGRATED_PAGES.agents).toBe("agents");
expect(MIGRATED_PAGES["router-settings"]).toBe("router-settings");
});

it("maps the users id to its route", async () => {
vi.doMock("@/components/networking", () => ({ serverRootPath: "/" }));
const { MIGRATED_PAGES } = await import("./migratedPages");

expect(MIGRATED_PAGES.users).toBe("users");
});
});

describe("dev server (NODE_ENV=development)", () => {
Expand Down
1 change: 1 addition & 0 deletions ui/litellm-dashboard/src/utils/migratedPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const MIGRATED_PAGES: Record<string, string> = {
new_usage: "usage",
agents: "agents",
"router-settings": "router-settings",
users: "users",
};

function uiBase(): string {
Expand Down
Loading