|
1 | | -import { Show, useContext, For } from "solid-js"; |
| 1 | +import { Show, useContext, For, createMemo } from "solid-js"; |
2 | 2 | import { OrgContext } from "../contexts/OrgContext"; |
3 | 3 | import { UserContext } from "../contexts/UserAuthContext"; |
4 | 4 | import { DatasetAndUsage } from "shared/types"; |
@@ -51,34 +51,44 @@ const navbarRoutes = [ |
51 | 51 | ]; |
52 | 52 |
|
53 | 53 | const dashboardURL = import.meta.env.VITE_DASHBOARD_URL as string; |
54 | | - |
55 | | -const domainNavbarRoutes = [ |
56 | | - { |
57 | | - href: dashboardURL, |
58 | | - label: "Dashboard", |
59 | | - icon: TbLayoutDashboard, |
60 | | - }, |
61 | | - { |
62 | | - href: "https://docs.trieve.ai/api-reference/", |
63 | | - label: "API Docs", |
64 | | - icon: AiOutlineApi, |
65 | | - }, |
66 | | - { |
67 | | - href: "https://search.trieve.ai", |
68 | | - label: "Search Playground", |
69 | | - icon: HiOutlineMagnifyingGlass, |
70 | | - }, |
71 | | - { |
72 | | - href: "https://chat.trieve.ai", |
73 | | - label: "Chat Playground", |
74 | | - icon: IoChatboxOutline, |
75 | | - }, |
76 | | -]; |
| 54 | +const searchUrl = import.meta.env.VITE_SEARCH_UI_URL as string; |
| 55 | +const chatUrl = import.meta.env.VITE_CHAT_UI_URL as string; |
77 | 56 |
|
78 | 57 | export const Sidebar = (props: NavbarProps) => { |
79 | 58 | const userContext = useContext(UserContext); |
80 | 59 | const orgContext = useContext(OrgContext); |
81 | 60 |
|
| 61 | + const domainNavbarRoutes = createMemo(() => { |
| 62 | + const domainNavbarRoutes = [ |
| 63 | + { |
| 64 | + href: `${dashboardURL}/dashboard/dataset/${props.selectedDataset |
| 65 | + ?.dataset.id}/start?org=${orgContext.selectedOrg().id}`, |
| 66 | + label: "Dashboard", |
| 67 | + icon: TbLayoutDashboard, |
| 68 | + }, |
| 69 | + { |
| 70 | + href: "https://docs.trieve.ai/api-reference/", |
| 71 | + label: "API Docs", |
| 72 | + icon: AiOutlineApi, |
| 73 | + }, |
| 74 | + { |
| 75 | + href: `${searchUrl}?organization=${ |
| 76 | + orgContext.selectedOrg().id |
| 77 | + }&dataset=${props.selectedDataset?.dataset.id}`, |
| 78 | + label: "Search Playground", |
| 79 | + icon: HiOutlineMagnifyingGlass, |
| 80 | + }, |
| 81 | + { |
| 82 | + href: `${chatUrl}?organization=${ |
| 83 | + orgContext.selectedOrg().id |
| 84 | + }&dataset=${props.selectedDataset?.dataset.id}`, |
| 85 | + label: "Chat Playground", |
| 86 | + icon: IoChatboxOutline, |
| 87 | + }, |
| 88 | + ]; |
| 89 | + return domainNavbarRoutes; |
| 90 | + }); |
| 91 | + |
82 | 92 | const pathname = usePathname(); |
83 | 93 | const navigate = useBetterNav(); |
84 | 94 |
|
@@ -172,23 +182,23 @@ export const Sidebar = (props: NavbarProps) => { |
172 | 182 | <div class="h-4 border-b border-neutral-400/50" /> |
173 | 183 |
|
174 | 184 | <div class="flex flex-col gap-2 px-2 pt-4"> |
175 | | - <For each={domainNavbarRoutes}> |
| 185 | + <For each={domainNavbarRoutes()}> |
176 | 186 | {(link) => { |
177 | 187 | return ( |
178 | | - <div |
| 188 | + <a |
179 | 189 | role="link" |
180 | 190 | classList={{ |
181 | | - "cursor-pointer flex items-center text-sm gap-2": true, |
| 191 | + "cursor-pointer flex items-center text-sm gap-2 hover:text-fuchsia-500": |
| 192 | + true, |
182 | 193 | "text-purple-900 underline": pathname() === link.href, |
183 | 194 | "text-black": pathname() !== link.href, |
184 | 195 | }} |
185 | | - onClick={() => { |
186 | | - window.open(link.href); |
187 | | - }} |
| 196 | + href={link.href} |
| 197 | + target="_blank" |
188 | 198 | > |
189 | 199 | {link.icon({ size: "14px" })} |
190 | 200 | {link.label} |
191 | | - </div> |
| 201 | + </a> |
192 | 202 | ); |
193 | 203 | }} |
194 | 204 | </For> |
|
0 commit comments