Skip to content

Commit 6529ed4

Browse files
committed
hidden dashboard routing, dev and build env files
1 parent b1f3553 commit 6529ed4

35 files changed

+207
-113
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
NODE_ENV=development
2+
NEXT_PUBLIC_BASE_URL=""
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
NODE_ENV=production
2+
NEXT_PUBLIC_BASE_URL="ui/"

ui/litellm-dashboard/src/app/dashboard/components/Sidebar2.tsx renamed to ui/litellm-dashboard/src/app/(dashboard)/components/Sidebar2.tsx

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ interface MenuItem {
4646
icon?: React.ReactNode;
4747
}
4848

49+
/** ---------- Base URL helpers ---------- */
50+
/** Normalizes NEXT_PUBLIC_BASE_URL into either "" or "/something" (no trailing slash). */
51+
const getBasePath = () => {
52+
const raw = process.env.NEXT_PUBLIC_BASE_URL ?? "";
53+
const trimmed = raw.replace(/^\/+|\/+$/g, ""); // strip leading/trailing slashes
54+
return trimmed ? `/${trimmed}` : "";
55+
};
56+
57+
/** Joins base path with a relative path like "virtual-keys" or "/virtual-keys" -> "/base/virtual-keys" */
58+
const withBase = (relativePath: string) => {
59+
const base = getBasePath(); // "" or "/ui" (no trailing slash)
60+
const rel = relativePath.replace(/^\/+/, ""); // drop any leading slash
61+
return `${base}/${rel}`.replace(/\/{2,}/g, "/"); // collapse accidental doubles
62+
};
63+
4964
const Sidebar2: React.FC<SidebarProps> = ({ accessToken, userRole, defaultSelectedKey, collapsed = false }) => {
5065
const menuItems: MenuItem[] = [
5166
{ key: "1", page: "api-keys", label: "Virtual Keys", icon: <KeyOutlined style={{ fontSize: 18 }} /> },
@@ -217,25 +232,31 @@ const Sidebar2: React.FC<SidebarProps> = ({ accessToken, userRole, defaultSelect
217232
return "1";
218233
};
219234

235+
// Match Virtual Keys path with base prefix (e.g., "/virtual-keys" or "/ui/virtual-keys")
236+
const virtualKeysPath = withBase("virtual-keys");
237+
220238
const selectedMenuKey =
221-
pathname === "/dashboard/virtual-keys"
239+
pathname === virtualKeysPath
222240
? "1"
223241
: pageParam
224242
? findMenuItemKey(pageParam)
225243
: defaultSelectedKey
226244
? findMenuItemKey(defaultSelectedKey)
227245
: "1";
228246

229-
// Root-only routing helper: always replace everything after the domain
230-
const rootWithPage = (p: string) => ({ pathname: "/", query: { page: p } });
247+
// Root-only routing helper: always replace everything after the domain, honoring base path
248+
const rootWithPage = (p: string) => ({
249+
pathname: getBasePath() || "/",
250+
query: { page: p },
251+
});
231252

232253
// Convert to AntD Menu items:
233-
// - "Virtual Keys" still routes to /virtual-keys
234-
// - All other items (and children) route to "/?page=<page>"
254+
// - "Virtual Keys" routes to "/<BASE>/virtual-keys"
255+
// - All other items (and children) route to "/<BASE>/?page=<page>"
235256
const antdItems = filteredMenuItems.map((item) => {
236257
const isVirtualKeys = item.key === "1";
237258
const label = isVirtualKeys ? (
238-
<Link href="/virtual-keys">Virtual Keys</Link>
259+
<Link href={withBase("virtual-keys")}>Virtual Keys</Link>
239260
) : (
240261
<Link href={rootWithPage(item.page)}>{item.label}</Link>
241262
);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"use client";
2+
3+
import Sidebar2 from "@/app/(dashboard)/components/Sidebar2";
4+
import Sidebar from "@/components/leftnav";
5+
import React from "react";
6+
import useFeatureFlags from "@/hooks/useFeatureFlags";
7+
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
8+
9+
interface SidebarProviderProps {
10+
defaultSelectedKey: string;
11+
sidebarCollapsed: boolean;
12+
setPage: (page: string) => void;
13+
}
14+
15+
const SidebarProvider = ({ defaultSelectedKey, sidebarCollapsed, setPage }: SidebarProviderProps) => {
16+
const { accessToken, userRole } = useAuthorized();
17+
const { refactoredUIFlag, setRefactoredUIFlag } = useFeatureFlags();
18+
19+
return refactoredUIFlag ? (
20+
<Sidebar2 accessToken={accessToken} userRole={userRole} />
21+
) : (
22+
<Sidebar
23+
accessToken={accessToken}
24+
setPage={setPage}
25+
userRole={userRole}
26+
defaultSelectedKey={defaultSelectedKey}
27+
collapsed={sidebarCollapsed}
28+
/>
29+
);
30+
};
31+
32+
export default SidebarProvider;

ui/litellm-dashboard/src/app/dashboard/components/modals/CreateUserModal.tsx renamed to ui/litellm-dashboard/src/app/(dashboard)/components/modals/CreateUserModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import {
2929
} from "@/components/networking";
3030
import { getModelDisplayName } from "@/components/key_team_helpers/fetch_available_models_team_key";
3131
import BulkCreateUsersButton from "@/components/bulk_create_users_button";
32-
import { fetchTeams } from "@/app/dashboard/virtual-keys/networking";
33-
import useTeams from "@/app/dashboard/virtual-keys/hooks/useTeams";
34-
import useAuthorized from "@/app/dashboard/hooks/useAuthorized";
32+
import { fetchTeams } from "@/app/(dashboard)/virtual-keys/networking";
33+
import useTeams from "@/app/(dashboard)/virtual-keys/hooks/useTeams";
34+
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
3535

3636
// Helper function to generate UUID compatible across all environments
3737
const generateUUID = (): string => {
File renamed without changes.

ui/litellm-dashboard/src/app/dashboard/layout.tsx renamed to ui/litellm-dashboard/src/app/(dashboard)/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import React from "react";
44
import Navbar from "@/components/navbar";
55
import { ThemeProvider } from "@/contexts/ThemeContext";
6-
import Sidebar2 from "@/app/dashboard/components/Sidebar2";
7-
import useAuthorized from "@/app/dashboard/hooks/useAuthorized";
6+
import Sidebar2 from "@/app/(dashboard)/components/Sidebar2";
7+
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
88

99
export default function Layout({ children }: { children: React.ReactNode }) {
1010
const { accessToken, userRole } = useAuthorized();

ui/litellm-dashboard/src/app/dashboard/virtual-keys/components/CreateKey.tsx renamed to ui/litellm-dashboard/src/app/(dashboard)/virtual-keys/components/CreateKey.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { Modal, Form } from "antd";
66
import { getPossibleUserRoles, Organization } from "@/components/networking";
77
import { rolesWithWriteAccess } from "@/utils/roles";
88
import { Team } from "@/components/key_team_helpers/key_list";
9-
import CreateKeyModal from "@/app/dashboard/virtual-keys/components/CreateKeyModal/CreateKeyModal";
10-
import CreateUserModal from "@/app/dashboard/components/modals/CreateUserModal";
11-
import useAuthorized from "@/app/dashboard/hooks/useAuthorized";
9+
import CreateKeyModal from "@/app/(dashboard)/virtual-keys/components/CreateKeyModal/CreateKeyModal";
10+
import CreateUserModal from "@/app/(dashboard)/components/modals/CreateUserModal";
11+
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
1212

1313
interface CreateKeyProps {
1414
team: Team | null;
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import SchemaFormFields from "@/components/common_components/check_openapi_schem
1717
import { Team } from "@/components/key_team_helpers/key_list";
1818
import React from "react";
1919
import { DefaultOptionType } from "rc-select/lib/Select";
20-
import { ModelAliases } from "@/app/dashboard/virtual-keys/components/CreateKeyModal/types";
20+
import { ModelAliases } from "@/app/(dashboard)/virtual-keys/components/CreateKeyModal/types";
2121

2222
export interface OptionalSettingsSectionProps {
2323
form: FormInstance;

0 commit comments

Comments
 (0)