in packages/dag-history-component/src/components/BookmarkList/index.tsx [39:87]
public render() {
const {
bookmarks,
onBookmarkClick,
onSelectState,
onSelectBookmarkDepth,
dragIndex,
hoverIndex,
dragKey,
onBookmarkEdit,
onBookmarkEditDone,
bookmarkEditIndex,
} = this.props
const bookmarkViews = bookmarks.map((s, index) => (
<Bookmark
{...s}
editMode={index === bookmarkEditIndex}
hoverIndex={hoverIndex}
dragIndex={dragIndex}
dragKey={dragKey}
key={`bookmark::${s.stateId}`}
index={index}
onBookmarkEdit={onBookmarkEdit}
onBookmarkEditDone={onBookmarkEditDone}
stateId={s.stateId}
onSelectBookmarkDepth={onSelectBookmarkDepth}
onClick={() => this.onBookmarkClick(index, s.stateId)}
onDiscoveryTrailIndexClicked={(selectedIndex: number) => {
const target = s.shortestCommitPath[selectedIndex]
onSelectBookmarkDepth({ target, depth: selectedIndex, state: target })
onSelectState(target)
}}
/>
))
if (dragKey && hoverIndex >= 0 && hoverIndex !== dragIndex) {
const dragged = bookmarkViews[dragIndex]
const adjustedHoverIndex =
hoverIndex < dragIndex ? hoverIndex : hoverIndex - 1
bookmarkViews.splice(dragIndex, 1)
bookmarkViews.splice(adjustedHoverIndex, 0, dragged)
}
return (
<Bookmarks>
{bookmarkViews.length > 0 ? bookmarkViews : <NoBookmarks />}
</Bookmarks>
)
}