* feat(tracker): add support for multi tab sessions
* feat(backend): added support of multitabs
* fix(backend): added support of deprecated batch meta message to pre-decoder
* fix(backend): fixed nil meta issue for TabData messages in sink
* feat(player): add tabmanager
* feat(player): basic tabchange event support
* feat(player): pick tabstate for console panel and timeline
* fix(player): only display tabs that are created
* feat(player): connect performance, xray and events to tab state
* feat(player): merge all tabs data for overview
* feat(backend/tracker): extract tabdata into separate message from batchmeta
* fix(tracker): fix new session check
* fix(backend): remove batchmetadeprecated
* fix(backend): fix switch case
* fix(player): fix for tab message size
* feat(tracker): check for active tabs with broadcast channel
* feat(tracker): prevent multiple messages
* fix(tracker): ignore beacons from same tab, only ask if token isnt present yet, add small delay before start to wait for answer
* feat(player): support new msg struct in assist player
* fix(player): fix some livepl components for multi tab states
* feat(tracker): add option to disable multitab
* feat(tracker): add multitab to assist plugin
* feat(player): back compat for tab id
* fix(ui): fix missing list in controls
* fix(ui): optional list update
* feat(ui): fix visuals for multitab; use window focus event for tabs
* fix(tracker): fix for dying tests (added tabid to writer, refactored other tests)
* feat(ui): update LivePlayerSubHeader.tsx to support tabs
* feat(backend): added tabs support to devtools mob files
* feat(ui): connect state to current tab properly
* feat(backend): added multitab support to assits
* feat(backend): removed data check in agent message
* feat(backend): debug on
* fix(backend): fixed typo in message broadcast
* feat(backend): fixed issue in connect method
* fix(assist): fixed typo
* feat(assist): added more debug logs
* feat(assist): removed one log
* feat(assist): more logs
* feat(assist): use query.peerId
* feat(assist): more logs
* feat(assist): fixed session update
* fix(assist): fixed getSessions
* fix(assist): fixed request_control broadcast
* fix(assist): fixed typo
* fix(assist): added missed line
* fix(assist): fix typo
* feat(tracker): multitab support for assist sessions
* fix(tracker): fix dead tests (tabid prop)
* fix(tracker): fix yaml
* fix(tracker): timers issue
* fix(ui): fix ui E2E tests with magic?
* feat(assist): multitabs support for ee version
* fix(assist): added missed method import
* fix(tracker): fix fix events in assist
* feat(assist): added back compatibility for sessions without tabId
* fix(assist): apply message's top layer structure before broadcast call
* fix(assist): added random tabID for prev version
* fix(assist): added random tabID for prev version (ee)
* feat(assist): added debug logs
* fix(assist): fix typo in sessions_agents_count method
* fix(assist): fixed more typos in copy-pastes
* fix(tracker): fix restart timings
* feat(backend): added tabIDs for some events
* feat(ui): add tab change event to the user steps bar
* Revert "feat(backend): added tabIDs for some events"
This reverts commit 1467ad7f9f.
* feat(ui): revert timeline and xray to grab events from all tabs
* fix(ui): fix typo
---------
Co-authored-by: Alexander Zavorotynskiy <zavorotynskiy@pm.me>
171 lines
5.3 KiB
TypeScript
171 lines
5.3 KiB
TypeScript
import React, { useEffect, useMemo, useState } from 'react';
|
|
import { observer } from 'mobx-react-lite';
|
|
import { Tabs, Input, NoContent, Icon } from 'UI';
|
|
import { List, CellMeasurer, AutoSizer } from 'react-virtualized';
|
|
import { PlayerContext } from 'App/components/Session/playerContext';
|
|
import BottomBlock from '../BottomBlock';
|
|
import { useModal } from 'App/components/Modal';
|
|
import { useStore } from 'App/mstore';
|
|
import { typeList } from 'Types/session/stackEvent';
|
|
import StackEventRow from 'Shared/DevTools/StackEventRow';
|
|
|
|
import StackEventModal from '../StackEventModal';
|
|
import useAutoscroll, { getLastItemTime } from '../useAutoscroll';
|
|
import { useRegExListFilterMemo, useTabListFilterMemo } from '../useListFilter'
|
|
import useCellMeasurerCache from 'App/hooks/useCellMeasurerCache'
|
|
|
|
const INDEX_KEY = 'stackEvent';
|
|
const ALL = 'ALL';
|
|
const TAB_KEYS = [ ALL, ...typeList] as const
|
|
const TABS = TAB_KEYS.map((tab) => ({ text: tab, key: tab }))
|
|
|
|
function StackEventPanel() {
|
|
const { player, store } = React.useContext(PlayerContext)
|
|
const jump = (t: number) => player.jump(t)
|
|
const { currentTab, tabStates } = store.get()
|
|
|
|
const {
|
|
stackList: list = [],
|
|
stackListNow: listNow = [],
|
|
} = tabStates[currentTab]
|
|
|
|
const {
|
|
sessionStore: { devTools },
|
|
} = useStore();
|
|
const { showModal } = useModal();
|
|
const [isDetailsModalActive, setIsDetailsModalActive] = useState(false) // TODO:embed that into useModal
|
|
const filter = devTools[INDEX_KEY].filter
|
|
const activeTab = devTools[INDEX_KEY].activeTab
|
|
const activeIndex = devTools[INDEX_KEY].index
|
|
|
|
let filteredList = useRegExListFilterMemo(list, it => it.name, filter)
|
|
filteredList = useTabListFilterMemo(filteredList, it => it.source, ALL, activeTab)
|
|
|
|
const onTabClick = (activeTab: typeof TAB_KEYS[number]) => devTools.update(INDEX_KEY, { activeTab })
|
|
const onFilterChange = ({ target: { value } }: React.ChangeEvent<HTMLInputElement>) => devTools.update(INDEX_KEY, { filter: value })
|
|
const tabs = useMemo(() =>
|
|
TABS.filter(({ key }) => key === ALL || list.some(({ source }) => key === source)),
|
|
[ list.length ],
|
|
)
|
|
|
|
const [
|
|
timeoutStartAutoscroll,
|
|
stopAutoscroll,
|
|
] = useAutoscroll(
|
|
filteredList,
|
|
getLastItemTime(listNow),
|
|
activeIndex,
|
|
index => devTools.update(INDEX_KEY, { index })
|
|
)
|
|
const onMouseEnter = stopAutoscroll
|
|
const onMouseLeave = () => {
|
|
if (isDetailsModalActive) { return }
|
|
timeoutStartAutoscroll()
|
|
}
|
|
|
|
const cache = useCellMeasurerCache()
|
|
|
|
const showDetails = (item: any) => {
|
|
setIsDetailsModalActive(true)
|
|
showModal(
|
|
<StackEventModal event={item} />,
|
|
{
|
|
right: true,
|
|
width: 500,
|
|
onClose: () => {
|
|
setIsDetailsModalActive(false)
|
|
timeoutStartAutoscroll()
|
|
}
|
|
}
|
|
)
|
|
devTools.update(INDEX_KEY, { index: filteredList.indexOf(item) })
|
|
stopAutoscroll()
|
|
}
|
|
|
|
const _list = React.useRef()
|
|
useEffect(() => {
|
|
if (_list.current) {
|
|
// @ts-ignore
|
|
_list.current.scrollToRow(activeIndex)
|
|
}
|
|
}, [ activeIndex ])
|
|
|
|
|
|
const _rowRenderer = ({ index, key, parent, style }: any) => {
|
|
const item = filteredList[index];
|
|
|
|
return (
|
|
// @ts-ignore
|
|
<CellMeasurer cache={cache} columnIndex={0} key={key} rowIndex={index} parent={parent}>
|
|
{() => (
|
|
<StackEventRow
|
|
isActive={activeIndex === index}
|
|
style={style}
|
|
key={item.key}
|
|
event={item}
|
|
onJump={() => {
|
|
stopAutoscroll()
|
|
devTools.update(INDEX_KEY, { index: filteredList.indexOf(item) });
|
|
jump(item.time);
|
|
}}
|
|
onClick={() => showDetails(item)}
|
|
/>
|
|
)}
|
|
</CellMeasurer>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<BottomBlock
|
|
style={{ height: '300px' }}
|
|
onMouseEnter={onMouseEnter}
|
|
onMouseLeave={onMouseLeave}
|
|
>
|
|
<BottomBlock.Header>
|
|
<div className="flex items-center">
|
|
<span className="font-semibold color-gray-medium mr-4">Stack Events</span>
|
|
<Tabs tabs={tabs} active={activeTab} onClick={onTabClick} border={false} />
|
|
</div>
|
|
<Input
|
|
className="input-small h-8"
|
|
placeholder="Filter by keyword"
|
|
icon="search"
|
|
name="filter"
|
|
height={28}
|
|
onChange={onFilterChange}
|
|
value={filter}
|
|
/>
|
|
</BottomBlock.Header>
|
|
<BottomBlock.Content className="overflow-y-auto">
|
|
<NoContent
|
|
title={
|
|
<div className="capitalize flex items-center mt-16">
|
|
<Icon name="info-circle" className="mr-2" size="18" />
|
|
No Data
|
|
</div>
|
|
}
|
|
size="small"
|
|
show={filteredList.length === 0}
|
|
>
|
|
<AutoSizer>
|
|
{({ height, width }: any) => (
|
|
<List
|
|
ref={_list}
|
|
deferredMeasurementCache={cache}
|
|
overscanRowCount={5}
|
|
rowCount={Math.ceil(filteredList.length || 1)}
|
|
rowHeight={cache.rowHeight}
|
|
rowRenderer={_rowRenderer}
|
|
width={width}
|
|
height={height}
|
|
scrollToAlignment="center"
|
|
/>
|
|
)}
|
|
</AutoSizer>
|
|
</NoContent>
|
|
</BottomBlock.Content>
|
|
</BottomBlock>
|
|
);
|
|
}
|
|
|
|
export default observer(StackEventPanel)
|