({
projects,
activeProjectId,
onProjectClick,
onDeleteProject,
onAchieveProject,
onPinProject,
onNewProject,
newProjectActive = false,
folded,
className,
}: ProjectNavListProps)
| 94 | |
| 95 | /** New Project row, optional Pinned section, and Projects section. */ |
| 96 | export function ProjectNavList({ |
| 97 | projects, |
| 98 | activeProjectId, |
| 99 | onProjectClick, |
| 100 | onDeleteProject, |
| 101 | onAchieveProject, |
| 102 | onPinProject, |
| 103 | onNewProject, |
| 104 | newProjectActive = false, |
| 105 | folded, |
| 106 | className, |
| 107 | }: ProjectNavListProps) { |
| 108 | const { t } = useTranslation(); |
| 109 | const projectListRef = useRef<HTMLDivElement>(null); |
| 110 | const [projectListOverflow, setProjectListOverflow] = useState(false); |
| 111 | |
| 112 | useEffect(() => { |
| 113 | const el = projectListRef.current; |
| 114 | if (!el) return; |
| 115 | |
| 116 | const checkOverflow = () => { |
| 117 | setProjectListOverflow(el.scrollHeight > el.clientHeight + 1); |
| 118 | }; |
| 119 | |
| 120 | checkOverflow(); |
| 121 | |
| 122 | const observer = new ResizeObserver(checkOverflow); |
| 123 | observer.observe(el); |
| 124 | Array.from(el.children).forEach((child) => observer.observe(child)); |
| 125 | |
| 126 | return () => observer.disconnect(); |
| 127 | }, [projects, folded]); |
| 128 | |
| 129 | const newProjectLabel = t('layout.new'); |
| 130 | const pinnedLabel = t('layout.pinned', { defaultValue: 'Pinned' }); |
| 131 | const projectsLabel = t('layout.projects', { defaultValue: 'Projects' }); |
| 132 | |
| 133 | const pinnedProjects = projects.filter((p) => p.pinned); |
| 134 | const unpinnedProjects = projects.filter((p) => !p.pinned); |
| 135 | const hasPinned = pinnedProjects.length > 0; |
| 136 | const hasUnpinned = unpinnedProjects.length > 0; |
| 137 | |
| 138 | const sharedRowProps = { |
| 139 | activeProjectId, |
| 140 | onProjectClick, |
| 141 | onDeleteProject, |
| 142 | onAchieveProject, |
| 143 | onPinProject, |
| 144 | folded, |
| 145 | }; |
| 146 | |
| 147 | return ( |
| 148 | <div |
| 149 | className={cn( |
| 150 | 'min-h-0 min-w-0 flex w-full flex-col overflow-hidden', |
| 151 | className |
| 152 | )} |
| 153 | > |
nothing calls this directly
no test coverage detected