({ model, row, focusIndex, setFocusIndex, setSearch, idx, handleFileContextMenu }: TableRowProps)
| 499 | }; |
| 500 | |
| 501 | function TableRow({ model, row, focusIndex, setFocusIndex, setSearch, idx, handleFileContextMenu }: TableRowProps) { |
| 502 | const dirPath = useAtomValue(model.statFilePath); |
| 503 | const connection = useAtomValue(model.connection); |
| 504 | |
| 505 | const dragItem: DraggedFile = { |
| 506 | relName: row.getValue("name") as string, |
| 507 | absParent: dirPath, |
| 508 | uri: formatRemoteUri(row.getValue("path") as string, connection), |
| 509 | isDir: row.original.isdir, |
| 510 | }; |
| 511 | const [_, drag] = useDrag( |
| 512 | () => ({ |
| 513 | type: "FILE_ITEM", |
| 514 | canDrag: true, |
| 515 | item: () => dragItem, |
| 516 | }), |
| 517 | [dragItem] |
| 518 | ); |
| 519 | |
| 520 | const dragRef = useCallback( |
| 521 | (node: HTMLDivElement | null) => { |
| 522 | drag(node); |
| 523 | }, |
| 524 | [drag] |
| 525 | ); |
| 526 | |
| 527 | return ( |
| 528 | <div |
| 529 | className={clsx("dir-table-body-row", { focused: focusIndex === idx })} |
| 530 | data-rowindex={idx} |
| 531 | onDoubleClick={() => { |
| 532 | const newFileName = row.getValue("path") as string; |
| 533 | model.goHistory(newFileName); |
| 534 | setSearch(""); |
| 535 | globalStore.set(model.directorySearchActive, false); |
| 536 | }} |
| 537 | onClick={() => setFocusIndex(idx)} |
| 538 | onContextMenu={(e) => handleFileContextMenu(e, row.original)} |
| 539 | ref={dragRef} |
| 540 | > |
| 541 | {row.getVisibleCells().map((cell) => ( |
| 542 | <div |
| 543 | className={clsx("dir-table-body-cell", "col-" + cell.column.id)} |
| 544 | key={cell.id} |
| 545 | style={{ width: `calc(var(--col-${cell.column.id}-size) * 1px)` }} |
| 546 | > |
| 547 | {flexRender(cell.column.columnDef.cell, cell.getContext())} |
| 548 | </div> |
| 549 | ))} |
| 550 | </div> |
| 551 | ); |
| 552 | } |
| 553 | |
| 554 | const MemoizedTableBody = React.memo( |
| 555 | TableBody, |
nothing calls this directly
no test coverage detected