Skip to content

Commit dce950e

Browse files
committed
refactor: enhance navigation functionality in File Manager
1 parent 06aeae6 commit dce950e

File tree

2 files changed

+89
-14
lines changed

2 files changed

+89
-14
lines changed

src-frontend/components/title-bar.tsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { cn } from "@/lib/utils";
33
import { useEffect, useRef, useState } from "react";
44
import { NotificationBell } from "@/components/notification-bell";
55
import { ThemeToggle } from "@/components/theme-toggle";
6-
import { Button } from "@/components/ui/button";
7-
import { ChevronLeft, ChevronRight } from "lucide-react";
86

97
export default function TitleBar({
108
className,
@@ -61,14 +59,6 @@ export default function TitleBar({
6159
};
6260
}, []);
6361

64-
const goBack = () => {
65-
window.history.back();
66-
};
67-
68-
const goForward = () => {
69-
window.history.forward();
70-
};
71-
7262
return (
7363
<div
7464
ref={titleBarRef}
@@ -90,11 +80,11 @@ export default function TitleBar({
9080
>
9181
<SidebarTrigger />
9282
<div className="flex items-center gap-1">
93-
<Button
83+
{/* <Button
9484
variant="ghost"
9585
size="sm"
9686
className="h-8 w-8 p-0"
97-
onClick={goBack}
87+
onClick={() => window.history.back()}
9888
aria-label="Go back"
9989
>
10090
<ChevronLeft className="h-4 w-4" />
@@ -103,11 +93,11 @@ export default function TitleBar({
10393
variant="ghost"
10494
size="sm"
10595
className="h-8 w-8 p-0"
106-
onClick={goForward}
96+
onClick={() => window.history.forward()}
10797
aria-label="Go forward"
10898
>
10999
<ChevronRight className="h-4 w-4" />
110-
</Button>
100+
</Button> */}
111101
</div>
112102
</div>
113103
<div className="flex items-center">{children}</div>

src-frontend/components/workspace/file-toolbar/file-actions.tsx

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,18 @@ import {
1717
ChevronDown,
1818
Square,
1919
CheckSquare,
20+
ArrowUp,
21+
ChevronLeft,
22+
ChevronRight,
2023
} from "lucide-react";
2124
import { Button } from "@/components/ui/button";
2225
import { Input } from "@/components/ui/input";
26+
import {
27+
Tooltip,
28+
TooltipContent,
29+
TooltipProvider,
30+
TooltipTrigger,
31+
} from "@/components/ui/tooltip";
2332
import {
2433
Dialog,
2534
DialogContent,
@@ -41,6 +50,7 @@ import {
4150
DropdownMenuSubContent,
4251
} from "@/components/ui/dropdown-menu";
4352
import { FileSystemItem } from "@/lib/types";
53+
import { Separator } from "@/components/ui/separator";
4454

4555
export function FileActions() {
4656
const {
@@ -59,6 +69,7 @@ export function FileActions() {
5969
setSortConfig,
6070
fileSystem,
6171
currentPath,
72+
navigateTo,
6273
viewMode,
6374
setViewMode,
6475
showHiddenFiles,
@@ -204,11 +215,85 @@ export function FileActions() {
204215
}
205216
};
206217

218+
const goBack = () => {
219+
window.history.back();
220+
};
221+
222+
const goForward = () => {
223+
window.history.forward();
224+
};
225+
207226
return (
208227
<>
209228
{/* Sync status button */}
210229
{/* {renderSyncStatusButton()} */}
211230

231+
{/* Navigation buttons */}
232+
<div className="flex items-center gap-1">
233+
<TooltipProvider>
234+
<Tooltip>
235+
<TooltipTrigger asChild>
236+
<Button
237+
variant="ghost"
238+
size="sm"
239+
className="h-8 w-8 p-0"
240+
onClick={goBack}
241+
aria-label="Go back"
242+
>
243+
<ChevronLeft className="h-4 w-4" />
244+
</Button>
245+
</TooltipTrigger>
246+
<TooltipContent>
247+
<p>Go back</p>
248+
</TooltipContent>
249+
</Tooltip>
250+
</TooltipProvider>
251+
252+
<TooltipProvider>
253+
<Tooltip>
254+
<TooltipTrigger asChild>
255+
<Button
256+
variant="ghost"
257+
size="sm"
258+
className="h-8 w-8 p-0"
259+
onClick={goForward}
260+
aria-label="Go forward"
261+
>
262+
<ChevronRight className="h-4 w-4" />
263+
</Button>
264+
</TooltipTrigger>
265+
<TooltipContent>
266+
<p>Go forward</p>
267+
</TooltipContent>
268+
</Tooltip>
269+
</TooltipProvider>
270+
</div>
271+
272+
<TooltipProvider>
273+
<Tooltip>
274+
<TooltipTrigger asChild>
275+
<div
276+
className={`inline-block ${currentPath.length === 0 ? "cursor-not-allowed" : ""}`}
277+
>
278+
<Button
279+
variant="ghost"
280+
size="sm"
281+
onClick={() => navigateTo(currentPath.slice(0, -1))}
282+
disabled={currentPath.length === 0}
283+
className="flex items-center gap-2"
284+
>
285+
<ArrowUp className="h-4 w-4" />
286+
</Button>
287+
</div>
288+
</TooltipTrigger>
289+
<TooltipContent>
290+
<p>{currentPath.length === 0 ? "At workspace root" : "Go up"}</p>
291+
</TooltipContent>
292+
</Tooltip>
293+
</TooltipProvider>
294+
295+
<Separator orientation="vertical" className="h-4" />
296+
212297
{isCompactView ? (
213298
/* Compact Menu - Single dropdown with all options */
214299
<div className="ml-1 flex items-center gap-1">

0 commit comments

Comments
 (0)