| ... | ... | @@ -1,6 +1,11 @@ |
| 1 | | import { ChartNoAxesColumnIcon, GitPullRequestIcon, SettingsIcon } from "lucide-react"; |
| 1 | import { |
| 2 | ArrowLeftIcon, |
| 3 | ChartNoAxesColumnIcon, |
| 4 | GitPullRequestIcon, |
| 5 | SettingsIcon, |
| 6 | } from "lucide-react"; |
| 2 | 7 | import { memo, useCallback } from "react"; |
| 3 | | import { Link, useNavigate } from "@tanstack/react-router"; |
| 8 | import { Link, useCanGoBack, useLocation, useNavigate } from "@tanstack/react-router"; |
| 4 | 9 | |
| 5 | 10 | import { useEnvironmentIdentificationMode } from "../../hooks/useSettings"; |
| 6 | 11 | import { cn } from "../../lib/utils"; |
| ... | ... | @@ -114,6 +119,15 @@ function T3Wordmark() { |
| 114 | 119 | export const SidebarChromeFooter = memo(function SidebarChromeFooter() { |
| 115 | 120 | const navigate = useNavigate(); |
| 116 | 121 | const { isMobile, setOpenMobile } = useSidebar(); |
| 122 | const canGoBack = useCanGoBack(); |
| 123 | const currentFooterPage = useLocation({ |
| 124 | select: (location) => |
| 125 | location.pathname === "/usage" |
| 126 | ? "usage" |
| 127 | : location.pathname === "/pull-requests" |
| 128 | ? "pull-requests" |
| 129 | : null, |
| 130 | }); |
| 117 | 131 | const primaryEnvironment = usePrimaryEnvironment(); |
| 118 | 132 | const pullRequestsSupported = |
| 119 | 133 | primaryEnvironment?.serverConfig?.environment.capabilities.pullRequests === true; |
| ... | ... | @@ -138,12 +152,28 @@ export const SidebarChromeFooter = memo(function SidebarChromeFooter() { |
| 138 | 152 | void navigate({ to: "/usage" }); |
| 139 | 153 | }, [isMobile, navigate, setOpenMobile]); |
| 140 | 154 | |
| 155 | const handleBackClick = useCallback(() => { |
| 156 | closeMobileSidebar(); |
| 157 | if (canGoBack) { |
| 158 | window.history.back(); |
| 159 | return; |
| 160 | } |
| 161 | void navigate({ to: "/" }); |
| 162 | }, [canGoBack, closeMobileSidebar, navigate]); |
| 163 | |
| 141 | 164 | return ( |
| 142 | 165 | <SidebarFooter className="p-[var(--sidebar-content-inset)]"> |
| 143 | 166 | <SidebarProviderUpdatePill /> |
| 144 | 167 | <SidebarUpdatePill /> |
| 145 | 168 | <SidebarMenu> |
| 146 | | {pullRequestsSupported ? ( |
| 169 | {currentFooterPage === "pull-requests" ? ( |
| 170 | <SidebarMenuItem> |
| 171 | <SidebarMenuButton onClick={handleBackClick}> |
| 172 | <ArrowLeftIcon /> |
| 173 | <span>Back</span> |
| 174 | </SidebarMenuButton> |
| 175 | </SidebarMenuItem> |
| 176 | ) : pullRequestsSupported ? ( |
| 147 | 177 | <SidebarMenuItem> |
| 148 | 178 | <SidebarMenuButton onClick={handlePullRequestsClick}> |
| 149 | 179 | <GitPullRequestIcon /> |
| ... | ... | @@ -151,12 +181,21 @@ export const SidebarChromeFooter = memo(function SidebarChromeFooter() { |
| 151 | 181 | </SidebarMenuButton> |
| 152 | 182 | </SidebarMenuItem> |
| 153 | 183 | ) : null} |
| 154 | | <SidebarMenuItem> |
| 155 | | <SidebarMenuButton onClick={handleUsageClick}> |
| 156 | | <ChartNoAxesColumnIcon /> |
| 157 | | <span>Usage</span> |
| 158 | | </SidebarMenuButton> |
| 159 | | </SidebarMenuItem> |
| 184 | {currentFooterPage === "usage" ? ( |
| 185 | <SidebarMenuItem> |
| 186 | <SidebarMenuButton onClick={handleBackClick}> |
| 187 | <ArrowLeftIcon /> |
| 188 | <span>Back</span> |
| 189 | </SidebarMenuButton> |
| 190 | </SidebarMenuItem> |
| 191 | ) : ( |
| 192 | <SidebarMenuItem> |
| 193 | <SidebarMenuButton onClick={handleUsageClick}> |
| 194 | <ChartNoAxesColumnIcon /> |
| 195 | <span>Usage</span> |
| 196 | </SidebarMenuButton> |
| 197 | </SidebarMenuItem> |
| 198 | )} |
| 160 | 199 | <SidebarMenuItem> |
| 161 | 200 | <SidebarMenuButton onClick={handleSettingsClick}> |
| 162 | 201 | <SettingsIcon /> |