-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "feat(replay): Add Jump up|down buttons to all the Replay Deta…
…ils tables & lists (#58131)" This reverts commit f078c6e. Co-authored-by: ryan953 <[email protected]>
- Loading branch information
1 parent
b5ac449
commit 28d42c9
Showing
12 changed files
with
66 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,65 @@ | ||
import {useCallback, useMemo, useState} from 'react'; | ||
import type {IndexRange, SectionRenderedParams} from 'react-virtualized'; | ||
import {ScrollParams} from 'react-virtualized'; | ||
|
||
import {getNextReplayFrame} from 'sentry/utils/replays/getReplayEvent'; | ||
import type {ReplayFrame} from 'sentry/utils/replays/types'; | ||
import {ReplayFrame} from 'sentry/utils/replays/types'; | ||
|
||
/** | ||
* The range (`[startIndex, endIndex]`) of table rows that are visible, | ||
* not including the table header. | ||
*/ | ||
type VisibleRange = [number, number]; | ||
|
||
interface Props { | ||
currentTime: number; | ||
frames: ReplayFrame[]; | ||
isTable: boolean; | ||
rowHeight: number; | ||
setScrollToRow: (row: number) => void; | ||
} | ||
|
||
export default function useJumpButtons({ | ||
currentTime, | ||
frames, | ||
isTable, | ||
rowHeight, | ||
setScrollToRow, | ||
}: Props) { | ||
const [visibleRange, setVisibleRange] = useState<IndexRange>({ | ||
startIndex: 0, | ||
stopIndex: 0, | ||
}); | ||
const [visibleRange, setVisibleRange] = useState<VisibleRange>([0, 0]); | ||
|
||
const frameIndex = useMemo(() => { | ||
const indexOfCurrentRow = useMemo(() => { | ||
const frame = getNextReplayFrame({ | ||
frames, | ||
targetOffsetMs: currentTime, | ||
allowExact: true, | ||
}); | ||
const index = frames.findIndex(spanFrame => frame === spanFrame); | ||
// index is -1 at end of replay, so use last index | ||
return index === -1 ? frames.length - 1 : index; | ||
const frameIndex = frames.findIndex(spanFrame => frame === spanFrame); | ||
// frameIndex is -1 at end of replay, so use last index | ||
const index = frameIndex === -1 ? frames.length - 1 : frameIndex; | ||
return index; | ||
}, [currentTime, frames]); | ||
|
||
// Tables have a header row, so we need to adjust for that. | ||
const rowIndex = isTable ? frameIndex + 1 : frameIndex; | ||
|
||
const handleClick = useCallback(() => { | ||
// When Jump Down, ensures purple line is visible and index needs to be 1 to jump to top of the list | ||
const jumpDownFurther = | ||
isTable && (rowIndex > visibleRange.stopIndex || rowIndex === 0); | ||
|
||
setScrollToRow(rowIndex + (jumpDownFurther ? 1 : 0)); | ||
}, [isTable, rowIndex, setScrollToRow, visibleRange]); | ||
|
||
const onRowsRendered = setVisibleRange; | ||
// When Jump Down, ensures purple line is visible and index needs to be 1 to jump to top of network list | ||
if (indexOfCurrentRow > visibleRange[1] || indexOfCurrentRow === 0) { | ||
setScrollToRow(indexOfCurrentRow + 1); | ||
} else { | ||
setScrollToRow(indexOfCurrentRow); | ||
} | ||
}, [indexOfCurrentRow, setScrollToRow, visibleRange]); | ||
|
||
const onSectionRendered = useCallback( | ||
({rowStartIndex, rowStopIndex}: SectionRenderedParams) => { | ||
setVisibleRange({startIndex: rowStartIndex, stopIndex: rowStopIndex}); | ||
const handleScroll = useCallback( | ||
({clientHeight, scrollTop}: ScrollParams) => { | ||
setVisibleRange([ | ||
Math.floor(scrollTop / rowHeight), | ||
Math.floor(scrollTop + clientHeight / rowHeight), | ||
]); | ||
}, | ||
[] | ||
[rowHeight] | ||
); | ||
|
||
return { | ||
showJumpUpButton: indexOfCurrentRow < visibleRange[0], | ||
showJumpDownButton: indexOfCurrentRow > visibleRange[1], | ||
handleClick, | ||
onRowsRendered, | ||
onSectionRendered, | ||
showJumpDownButton: rowIndex > visibleRange.stopIndex, | ||
showJumpUpButton: rowIndex < visibleRange.startIndex, | ||
handleScroll, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
static/app/views/replays/detail/accessibility/useSortAccessibility.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.