import { getRE } from 'App/utils'; import { Label, NoContent, Input, SlideModal, CloseButton } from 'UI'; import { connectPlayer, pause, jump } from 'Player'; // import Autoscroll from '../Autoscroll'; import BottomBlock from '../BottomBlock'; import TimeTable from '../TimeTable'; import FetchDetails from './FetchDetails'; import { renderName, renderDuration } from '../Network'; import { connect } from 'react-redux'; import { setTimelinePointer } from 'Duck/sessions'; @connectPlayer(state => ({ list: state.fetchList, })) @connect(state => ({ timelinePointer: state.getIn(['sessions', 'timelinePointer']), }), { setTimelinePointer }) export default class Fetch extends React.PureComponent { state = { filter: "", filteredList: this.props.list, current: null, currentIndex: 0, showFetchDetails: false, hasNextError: false, hasPreviousError: false, } onFilterChange = (e, { value }) => { const { list } = this.props; const filterRE = getRE(value, 'i'); const filtered = list .filter((r) => filterRE.test(r.name) || filterRE.test(r.url) || filterRE.test(r.method) || filterRE.test(r.status)); this.setState({ filter: value, filteredList: value ? filtered : list, currentIndex: 0 }); } setCurrent = (item, index) => { pause() jump(item.time) this.setState({ current: item, currentIndex: index }); } onRowClick = (item, index) => { pause() this.setState({ current: item, currentIndex: index, showFetchDetails: true }); this.props.setTimelinePointer(null); } closeModal = () => this.setState({ current: null, showFetchDetails: false }); nextClickHander = () => { // const { list } = this.props; const { currentIndex, filteredList } = this.state; if (currentIndex === filteredList.length - 1) return; const newIndex = currentIndex + 1; this.setCurrent(filteredList[newIndex], newIndex); this.setState({ showFetchDetails: true }); } prevClickHander = () => { // const { list } = this.props; const { currentIndex, filteredList } = this.state; if (currentIndex === 0) return; const newIndex = currentIndex - 1; this.setCurrent(filteredList[newIndex], newIndex); this.setState({ showFetchDetails: true }); } static getDerivedStateFromProps(nextProps, prevState) { const { filteredList } = prevState; if (nextProps.timelinePointer) { let activeItem = filteredList.find((r) => r.time >= nextProps.timelinePointer.time); activeItem = activeItem || filteredList[filteredList.length - 1]; return { current: activeItem, currentIndex: filteredList.indexOf(activeItem), }; } } render() { // const { list } = this.props; const { current, currentIndex, showFetchDetails, filteredList } = this.state; return (

Fetch Request

Status
} isDisplayed={ current != null && showFetchDetails } content={ current && showFetchDetails && } onClose={ this.closeModal } />

Fetch

{/*
Prev
Next
*/}
{[ { label: "Status", dataKey: 'status', width: 70, }, { label: "Method", dataKey: "method", width: 60, }, { label: "Name", width: 180, render: renderName, }, { label: "Time", width: 80, render: renderDuration, } ]}
); } }