-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[Feat] UI - Add Open in New Tab on leftnav Bar #22731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| model_list: | ||
| - model_name: fake-openai-endpoint | ||
| litellm_params: | ||
| model: openai/fake-model | ||
| api_key: fake-key | ||
| api_base: https://exampleopenaiendpoint-production.up.railway.app/ | ||
|
|
||
| general_settings: | ||
| master_key: sk-1234 | ||
|
|
||
| litellm_settings: | ||
| drop_params: True | ||
| telemetry: False | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -374,6 +374,27 @@ const Sidebar2: React.FC<SidebarProps> = ({ accessToken, userRole, defaultSelect | |||||
| router.push(href); | ||||||
| }; | ||||||
|
|
||||||
| // Wrap label in <a> so every nav item supports right-click → "Open in new tab" | ||||||
| // and Ctrl/Cmd+click to open in a new tab, while preserving SPA navigation for normal clicks. | ||||||
| const renderNavLink = (label: string, page: string): React.ReactNode => { | ||||||
| const href = toHref(page); | ||||||
| return ( | ||||||
| <a | ||||||
| href={href} | ||||||
| onClick={(e) => { | ||||||
| if (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1) { | ||||||
| e.stopPropagation(); | ||||||
| return; | ||||||
| } | ||||||
| e.preventDefault(); | ||||||
| }} | ||||||
| style={{ color: "inherit", textDecoration: "none" }} | ||||||
| > | ||||||
| {label} | ||||||
| </a> | ||||||
| ); | ||||||
| }; | ||||||
|
|
||||||
| return ( | ||||||
| <Layout style={{ minHeight: "100vh" }}> | ||||||
| <Sider | ||||||
|
|
@@ -412,11 +433,11 @@ const Sidebar2: React.FC<SidebarProps> = ({ accessToken, userRole, defaultSelect | |||||
| items={filteredMenuItems.map((item) => ({ | ||||||
| key: item.key, | ||||||
| icon: item.icon, | ||||||
| label: item.label, | ||||||
| label: renderNavLink(item.label, item.page), | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parent submenu items get invalid hrefs
Consider skipping the
Suggested change
|
||||||
| children: item.children?.map((child) => ({ | ||||||
| key: child.key, | ||||||
| icon: child.icon, | ||||||
| label: child.label, | ||||||
| label: renderNavLink(child.label, child.page), | ||||||
| onClick: () => goTo(child.page), | ||||||
| })), | ||||||
| onClick: !item.children ? () => goTo(item.page) : undefined, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -374,6 +374,46 @@ const Sidebar: React.FC<SidebarProps> = ({ setPage, defaultSelectedKey, collapse | |||||
| setPage(page); | ||||||
| }; | ||||||
|
|
||||||
| // Wrap label in <a> so every nav item supports right-click → "Open in new tab" | ||||||
| // and Ctrl/Cmd+click to open in a new tab, while preserving SPA navigation for normal clicks. | ||||||
| const renderNavLink = ( | ||||||
| label: React.ReactNode, | ||||||
| page: string, | ||||||
| externalUrl?: string, | ||||||
| ): React.ReactNode => { | ||||||
| if (externalUrl) { | ||||||
| return ( | ||||||
| <a | ||||||
| href={externalUrl} | ||||||
| target="_blank" | ||||||
| rel="noopener noreferrer" | ||||||
| onClick={(e) => e.stopPropagation()} | ||||||
| style={{ color: "inherit", textDecoration: "none" }} | ||||||
| > | ||||||
| {label} | ||||||
| </a> | ||||||
| ); | ||||||
| } | ||||||
| const params = new URLSearchParams(window.location.search); | ||||||
| params.set("page", page); | ||||||
| const href = `?${params.toString()}`; | ||||||
| return ( | ||||||
| <a | ||||||
| href={href} | ||||||
| onClick={(e) => { | ||||||
| if (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1) { | ||||||
| e.stopPropagation(); | ||||||
| return; | ||||||
| } | ||||||
| e.preventDefault(); | ||||||
| }} | ||||||
| style={{ color: "inherit", textDecoration: "none" }} | ||||||
| > | ||||||
| {label} | ||||||
| </a> | ||||||
| ); | ||||||
| }; | ||||||
|
|
||||||
| // Filter items based on user role and enabled pages for internal users | ||||||
| const filterItemsByRole = (items: MenuItem[]): MenuItem[] => { | ||||||
| const isAdmin = isAdminRole(userRole); | ||||||
|
|
@@ -469,11 +509,11 @@ const Sidebar: React.FC<SidebarProps> = ({ setPage, defaultSelectedKey, collapse | |||||
| children: filteredItems.map((item) => ({ | ||||||
| key: item.key, | ||||||
| icon: item.icon, | ||||||
| label: item.label, | ||||||
| label: renderNavLink(item.label, item.page, item.external_url), | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parent submenu items get invalid hrefs Same issue as in Consider skipping the
Suggested change
|
||||||
| children: item.children?.map((child) => ({ | ||||||
| key: child.key, | ||||||
| icon: child.icon, | ||||||
| label: child.label, | ||||||
| label: renderNavLink(child.label, child.page, child.external_url), | ||||||
| onClick: () => { | ||||||
| if (child.external_url) { | ||||||
| window.open(child.external_url, "_blank"); | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dev config should be gitignored
This file contains a
master_keyandapi_key. While these are clearly dummy/fake values, committing dev config files to the repo creates a risk pattern — contributors may update this file with real credentials. The.gitignorealready excludesconfig.yamland various other config files, butdev_config.yamlis not listed.Consider adding
dev_config.yamlto.gitignoreto prevent accidental credential leaks.