diff --git a/memento-note/components/agents/agent-detail-view.tsx b/memento-note/components/agents/agent-detail-view.tsx index 3c0b218..9976ebb 100644 --- a/memento-note/components/agents/agent-detail-view.tsx +++ b/memento-note/components/agents/agent-detail-view.tsx @@ -97,7 +97,7 @@ interface AgentDetailViewProps { _count: { actions: number } actions: { id: string; status: string; createdAt: string | Date }[] } | null - notebooks: { id: string; name: string; icon?: string | null }[] + notebooks: { id: string; name: string; icon?: string | null; parentId?: string | null }[] onSave: (data: FormData) => Promise onBack: () => void onOpenLogs: (agentId: string, agentName: string) => void @@ -494,8 +494,13 @@ export function AgentDetailView({ className={selectCls} > - {notebooks.map(nb => ( - + {notebooks.filter(nb => !nb.parentId).map(nb => ( + + + {notebooks.filter(c => c.parentId === nb.id).map(child => ( + + ))} + ))} @@ -645,8 +650,13 @@ export function AgentDetailView({ diff --git a/memento-note/components/note-card.tsx b/memento-note/components/note-card.tsx index a9d9d1b..61d9fb5 100644 --- a/memento-note/components/note-card.tsx +++ b/memento-note/components/note-card.tsx @@ -504,18 +504,27 @@ export const NoteCard = memo(function NoteCard({ {t('notebookSuggestion.generalNotes')} - {notebooks.map((notebook: any) => { - const NotebookIcon = getNotebookIcon(notebook.icon || 'folder') - return ( - handleMoveToNotebook(notebook.id)} - > - - {notebook.name} - - ) - })} + {notebooks.filter(nb => !nb.parentId).map((notebook: any) => { + const NotebookIcon = getNotebookIcon(notebook.icon || 'folder') + const children = notebooks.filter((c: any) => c.parentId === notebook.id) + return ( +
+ handleMoveToNotebook(notebook.id)}> + + {notebook.name} + + {children.map((child: any) => { + const ChildIcon = getNotebookIcon(child.icon || 'folder') + return ( + handleMoveToNotebook(child.id)} className="pl-8"> + + └ {child.name} + + ) + })} +
+ ) + })} } diff --git a/memento-note/components/notebook-tree-select.tsx b/memento-note/components/notebook-tree-select.tsx new file mode 100644 index 0000000..9d2b77c --- /dev/null +++ b/memento-note/components/notebook-tree-select.tsx @@ -0,0 +1,94 @@ +'use client' + +import { Notebook } from '@/lib/types' + +interface NotebookTreeSelectProps { + notebooks: Notebook[] + value: string | null + onChange: (notebookId: string | null) => void + placeholder?: string + inboxLabel?: string + className?: string +} + +export function buildNotebookTree(notebooks: Notebook[]): { roots: Notebook[]; children: Map } { + const roots: Notebook[] = [] + const children = new Map() + for (const nb of notebooks) { + if (nb.parentId) { + const arr = children.get(nb.parentId) || [] + arr.push(nb) + children.set(nb.parentId, arr) + } else { + roots.push(nb) + } + } + return { roots, children } +} + +export function NotebookTreeSelect({ notebooks, value, onChange, placeholder, inboxLabel, className }: NotebookTreeSelectProps) { + const { roots, children } = buildNotebookTree(notebooks) + + return ( + + ) +} + +export function NotebookTreeList({ notebooks, activeNotebookId, onSelect, inboxLabel }: { + notebooks: Notebook[] + activeNotebookId: string | null + onSelect: (notebookId: string | null) => void + inboxLabel?: string +}) { + const { roots, children } = buildNotebookTree(notebooks) + + return ( + <> + {inboxLabel && ( + + )} + {roots.map(nb => ( +
+ + {(children.get(nb.id) || []).map(child => ( + + ))} +
+ ))} + + ) +} diff --git a/memento-note/components/notes-tabs-view.tsx b/memento-note/components/notes-tabs-view.tsx index 215de8c..840de18 100644 --- a/memento-note/components/notes-tabs-view.tsx +++ b/memento-note/components/notes-tabs-view.tsx @@ -547,23 +547,36 @@ function NoteMetaSidebar({ : } {t('notes.generalNotes')} - {notebooks.map((nb) => ( - - ))} - + {notebooks.filter(nb => !nb.parentId).map((nb) => ( +
+ + {notebooks.filter(c => c.parentId === nb.id).map(child => ( + + ))} +
+ ))} + {/* Pin / Unpin */}