@hienlh/ppm 0.11.0 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,9 @@ import {
11
11
  ChevronDown,
12
12
  Download,
13
13
  Loader2,
14
+ FilePlus,
15
+ FolderPlus,
16
+ RefreshCw,
14
17
  } from "lucide-react";
15
18
  import { useShallow } from "zustand/react/shallow";
16
19
  import { useFileStore, type FileNode } from "@/stores/file-store";
@@ -28,6 +31,9 @@ import {
28
31
  import { FileActions } from "./file-actions";
29
32
  import { downloadFile, downloadFolder } from "@/lib/file-download";
30
33
 
34
+ /** Synthetic root node for creating files/folders at project root */
35
+ const ROOT_NODE: FileNode = { name: "", path: "", type: "directory" };
36
+
31
37
  const FILE_ICON_MAP: Record<string, React.ComponentType<{ className?: string }>> = {
32
38
  ts: FileCode,
33
39
  tsx: FileCode,
@@ -301,25 +307,61 @@ export function FileTree({ onFileOpen }: FileTreeProps = {}) {
301
307
  return a.name.localeCompare(b.name);
302
308
  });
303
309
 
310
+ const toolbarBtnClass = "p-1 rounded-sm text-text-secondary hover:text-foreground hover:bg-surface-elevated transition-colors";
311
+
304
312
  return (
305
- <>
306
- <ScrollArea className="flex-1">
307
- <div className="py-1">
308
- {sorted.map((node) => (
309
- <TreeNode
310
- key={node.path}
311
- node={node}
312
- depth={0}
313
- projectName={activeProject.name}
314
- onAction={handleAction}
315
- onFileOpen={onFileOpen}
316
- />
317
- ))}
318
- {sorted.length === 0 && (
319
- <p className="p-3 text-xs text-text-subtle">Empty project.</p>
320
- )}
321
- </div>
322
- </ScrollArea>
313
+ <div className="flex flex-col h-full">
314
+ {/* Toolbar */}
315
+ <div className="flex items-center gap-0.5 px-2 h-8 border-b border-border shrink-0">
316
+ <button onClick={() => handleAction("new-file", ROOT_NODE)} title="New File" className={toolbarBtnClass}>
317
+ <FilePlus className="size-3.5" />
318
+ </button>
319
+ <button onClick={() => handleAction("new-folder", ROOT_NODE)} title="New Folder" className={toolbarBtnClass}>
320
+ <FolderPlus className="size-3.5" />
321
+ </button>
322
+ <div className="flex-1" />
323
+ <button onClick={loadTree} title="Refresh" className={toolbarBtnClass}>
324
+ <RefreshCw className="size-3.5" />
325
+ </button>
326
+ </div>
327
+
328
+ {/* File tree with blank-area context menu */}
329
+ <ContextMenu>
330
+ <ContextMenuTrigger asChild>
331
+ <ScrollArea className="flex-1">
332
+ <div className="py-1">
333
+ {sorted.map((node) => (
334
+ <TreeNode
335
+ key={node.path}
336
+ node={node}
337
+ depth={0}
338
+ projectName={activeProject.name}
339
+ onAction={handleAction}
340
+ onFileOpen={onFileOpen}
341
+ />
342
+ ))}
343
+ {sorted.length === 0 && (
344
+ <p className="p-3 text-xs text-text-subtle">Empty project.</p>
345
+ )}
346
+ </div>
347
+ </ScrollArea>
348
+ </ContextMenuTrigger>
349
+ <ContextMenuContent>
350
+ <ContextMenuItem onClick={() => handleAction("new-file", ROOT_NODE)}>
351
+ <FilePlus className="size-3.5 mr-2" />
352
+ New File
353
+ </ContextMenuItem>
354
+ <ContextMenuItem onClick={() => handleAction("new-folder", ROOT_NODE)}>
355
+ <FolderPlus className="size-3.5 mr-2" />
356
+ New Folder
357
+ </ContextMenuItem>
358
+ <ContextMenuSeparator />
359
+ <ContextMenuItem onClick={loadTree}>
360
+ <RefreshCw className="size-3.5 mr-2" />
361
+ Refresh
362
+ </ContextMenuItem>
363
+ </ContextMenuContent>
364
+ </ContextMenu>
323
365
 
324
366
  {actionState && (
325
367
  <FileActions
@@ -330,6 +372,6 @@ export function FileTree({ onFileOpen }: FileTreeProps = {}) {
330
372
  onRefresh={loadTree}
331
373
  />
332
374
  )}
333
- </>
375
+ </div>
334
376
  );
335
377
  }