(props: ProjectsPanelProps)
| 140 | } |
| 141 | |
| 142 | export default function ProjectsPanel(props: ProjectsPanelProps): JSX.Element { |
| 143 | const { source, project } = props; |
| 144 | const pollMs = props.pollMs ?? POLL_MS; |
| 145 | const root = useRef<HTMLDivElement | null>(null); |
| 146 | const mounted = useRef(true); |
| 147 | |
| 148 | // ------------------------------------------------------------ the list -- |
| 149 | const [projects, setProjects] = useState<ProjectEntry[] | undefined>(undefined); |
| 150 | const [listError, setListError] = useState(''); |
| 151 | const [listNotice, setListNotice] = useState(''); |
| 152 | const [health, setHealth] = useState<Record<string, HealthState>>({}); |
| 153 | const [armed, setArmed] = useState(''); |
| 154 | |
| 155 | // ------------------------------------------------------------ the form -- |
| 156 | const [path, setPath] = useState(''); |
| 157 | const [name, setName] = useState(''); |
| 158 | const [nameTouched, setNameTouched] = useState(false); |
| 159 | const [browseLevel, setBrowseLevel] = useState<BrowseLevel | undefined>(undefined); |
| 160 | const [browseError, setBrowseError] = useState(''); |
| 161 | const [startNotice, setStartNotice] = useState(''); |
| 162 | const [jobs, setJobs] = useState<IndexJob[]>([]); |
| 163 | const jobsRef = useRef<IndexJob[]>([]); |
| 164 | |
| 165 | // ------------------------------------------------------------- the adr -- |
| 166 | const [adr, setAdr] = useState<{ state: 'idle' | 'loading' | 'ready' | 'error'; record?: AdrRecord; detail: string }>({ |
| 167 | state: 'idle', |
| 168 | detail: '', |
| 169 | }); |
| 170 | const [adrDraft, setAdrDraft] = useState(''); |
| 171 | const [adrNotice, setAdrNotice] = useState(''); |
| 172 | |
| 173 | // ---------------------------------------------------------- the server -- |
| 174 | const [processes, setProcesses] = useState<ProcessReport | undefined>(undefined); |
| 175 | const [processesError, setProcessesError] = useState(''); |
| 176 | const [logs, setLogs] = useState<LogTail | undefined>(undefined); |
| 177 | const [logsError, setLogsError] = useState(''); |
| 178 | const [uiLog, setUiLog] = useState<UiLogTail | undefined>(undefined); |
| 179 | const [uiLogError, setUiLogError] = useState(''); |
| 180 | |
| 181 | useEffect(() => { |
| 182 | mounted.current = true; |
| 183 | root.current?.focus(); |
| 184 | return () => { |
| 185 | mounted.current = false; |
| 186 | }; |
| 187 | }, []); |
| 188 | |
| 189 | const loadProjects = useCallback(async () => { |
| 190 | try { |
| 191 | const list = await source.listProjects(); |
| 192 | if (!mounted.current) { |
| 193 | return; |
| 194 | } |
| 195 | setProjects(list); |
| 196 | setListError(''); |
| 197 | } catch (error) { |
| 198 | if (mounted.current) { |
| 199 | setListError(text.listError(describeError(error))); |
nothing calls this directly
no test coverage detected