* 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>
208 lines
6.4 KiB
TypeScript
208 lines
6.4 KiB
TypeScript
import React from 'react';
|
|
import { connect } from 'react-redux';
|
|
import cn from 'classnames';
|
|
import { Icon } from 'UI';
|
|
import { List, AutoSizer, CellMeasurer } from 'react-virtualized';
|
|
import { TYPES } from 'Types/session/event';
|
|
import { setEventFilter, filterOutNote } from 'Duck/sessions';
|
|
import EventGroupWrapper from './EventGroupWrapper';
|
|
import styles from './eventsBlock.module.css';
|
|
import EventSearch from './EventSearch/EventSearch';
|
|
import { PlayerContext } from 'App/components/Session/playerContext';
|
|
import { observer } from 'mobx-react-lite';
|
|
import { RootStore } from 'App/duck';
|
|
import useCellMeasurerCache from 'App/hooks/useCellMeasurerCache';
|
|
import { InjectedEvent } from 'Types/session/event';
|
|
import Session, { mergeEventLists } from 'Types/session';
|
|
|
|
interface IProps {
|
|
setEventFilter: (filter: { query: string }) => void;
|
|
filteredEvents: InjectedEvent[];
|
|
setActiveTab: (tab?: string) => void;
|
|
query: string;
|
|
events: Session['events'];
|
|
notesWithEvents: Session['notesWithEvents'];
|
|
filterOutNote: (id: string) => void;
|
|
eventsIndex: number[];
|
|
}
|
|
|
|
function EventsBlock(props: IProps) {
|
|
const [mouseOver, setMouseOver] = React.useState(true);
|
|
const scroller = React.useRef<List>(null);
|
|
const cache = useCellMeasurerCache({
|
|
fixedWidth: true,
|
|
defaultHeight: 300,
|
|
});
|
|
|
|
const { store, player } = React.useContext(PlayerContext);
|
|
|
|
const { playing, tabStates, tabChangeEvents } = store.get();
|
|
|
|
const {
|
|
filteredEvents,
|
|
eventsIndex,
|
|
filterOutNote,
|
|
query,
|
|
setActiveTab,
|
|
notesWithEvents = [],
|
|
} = props;
|
|
|
|
const filteredLength = filteredEvents?.length || 0;
|
|
const notesWithEvtsLength = notesWithEvents?.length || 0;
|
|
const eventListNow = Object.values(tabStates).reduce((acc: any[], tab) => {
|
|
return acc.concat(tab.eventListNow)
|
|
}, [])
|
|
|
|
const currentTimeEventIndex = eventListNow.length > 0 ? eventListNow.length - 1 : 0;
|
|
const usedEvents = React.useMemo(() => {
|
|
return mergeEventLists(filteredEvents || notesWithEvents, tabChangeEvents);
|
|
}, [filteredLength, notesWithEvtsLength])
|
|
|
|
const write = ({ target: { value } }: React.ChangeEvent<HTMLInputElement>) => {
|
|
props.setEventFilter({ query: value });
|
|
|
|
setTimeout(() => {
|
|
if (!scroller.current) return;
|
|
|
|
scroller.current.scrollToRow(0);
|
|
}, 100);
|
|
};
|
|
|
|
const clearSearch = () => {
|
|
props.setEventFilter({ query: '' });
|
|
if (scroller.current) {
|
|
scroller.current.forceUpdateGrid();
|
|
}
|
|
|
|
setTimeout(() => {
|
|
if (!scroller.current) return;
|
|
|
|
scroller.current.scrollToRow(0);
|
|
}, 100);
|
|
};
|
|
|
|
React.useEffect(() => {
|
|
return () => {
|
|
clearSearch();
|
|
};
|
|
}, []);
|
|
React.useEffect(() => {
|
|
if (scroller.current) {
|
|
scroller.current.forceUpdateGrid();
|
|
if (!mouseOver) {
|
|
scroller.current.scrollToRow(currentTimeEventIndex);
|
|
}
|
|
}
|
|
}, [currentTimeEventIndex]);
|
|
|
|
const onEventClick = (_: React.MouseEvent, event: { time: number }) => {
|
|
player.jump(event.time);
|
|
props.setEventFilter({ query: '' });
|
|
};
|
|
const onMouseOver = () => setMouseOver(true);
|
|
const onMouseLeave = () => setMouseOver(false);
|
|
|
|
const renderGroup = ({
|
|
index,
|
|
key,
|
|
style,
|
|
parent,
|
|
}: {
|
|
index: number;
|
|
key: string;
|
|
style: React.CSSProperties;
|
|
parent: any;
|
|
}) => {
|
|
const isLastEvent = index === usedEvents.length - 1;
|
|
const isLastInGroup = isLastEvent || usedEvents[index + 1]?.type === TYPES.LOCATION;
|
|
const event = usedEvents[index];
|
|
const isNote = 'noteId' in event;
|
|
const isTabChange = event.type === 'TABCHANGE';
|
|
const isCurrent = index === currentTimeEventIndex;
|
|
|
|
const heightBug =
|
|
index === 0 && event?.type === TYPES.LOCATION && 'referrer' in event ? { top: 2 } : {};
|
|
return (
|
|
<CellMeasurer key={key} cache={cache} parent={parent} rowIndex={index}>
|
|
{({ measure, registerChild }) => (
|
|
<div style={{ ...style, ...heightBug }} ref={registerChild}>
|
|
<EventGroupWrapper
|
|
query={query}
|
|
presentInSearch={eventsIndex.includes(index)}
|
|
isFirst={index == 0}
|
|
mesureHeight={measure}
|
|
onEventClick={onEventClick}
|
|
event={event}
|
|
isLastEvent={isLastEvent}
|
|
isLastInGroup={isLastInGroup}
|
|
isCurrent={isCurrent}
|
|
showSelection={!playing}
|
|
isNote={isNote}
|
|
isTabChange={isTabChange}
|
|
filterOutNote={filterOutNote}
|
|
/>
|
|
</div>
|
|
)}
|
|
</CellMeasurer>
|
|
);
|
|
};
|
|
|
|
const isEmptySearch = query && (usedEvents.length === 0 || !usedEvents);
|
|
const eventsText = `${query ? 'Filtered' : ''} ${usedEvents.length} Events`;
|
|
return (
|
|
<>
|
|
<div className={cn(styles.header, 'p-4')}>
|
|
<div className={cn(styles.hAndProgress, 'mt-3')}>
|
|
<EventSearch onChange={write} setActiveTab={setActiveTab} value={query} />
|
|
</div>
|
|
<div className="mt-1 color-gray-medium">{eventsText}</div>
|
|
</div>
|
|
<div
|
|
className={cn('flex-1 pb-4', styles.eventsList)}
|
|
id="eventList"
|
|
data-openreplay-masked
|
|
onMouseOver={onMouseOver}
|
|
onMouseLeave={onMouseLeave}
|
|
>
|
|
{isEmptySearch && (
|
|
<div className="flex items-center p-4">
|
|
<Icon name="binoculars" size={18} />
|
|
<span className="ml-2">No Matching Results</span>
|
|
</div>
|
|
)}
|
|
<AutoSizer disableWidth>
|
|
{({ height }) => (
|
|
<List
|
|
ref={scroller}
|
|
className={styles.eventsList}
|
|
height={height + 10}
|
|
width={270}
|
|
overscanRowCount={6}
|
|
itemSize={230}
|
|
rowCount={usedEvents.length}
|
|
deferredMeasurementCache={cache}
|
|
rowHeight={cache.rowHeight}
|
|
rowRenderer={renderGroup}
|
|
scrollToAlignment="center"
|
|
/>
|
|
)}
|
|
</AutoSizer>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default connect(
|
|
(state: RootStore) => ({
|
|
session: state.getIn(['sessions', 'current']),
|
|
notesWithEvents: state.getIn(['sessions', 'current']).notesWithEvents,
|
|
events: state.getIn(['sessions', 'current']).events,
|
|
filteredEvents: state.getIn(['sessions', 'filteredEvents']),
|
|
query: state.getIn(['sessions', 'eventsQuery']),
|
|
eventsIndex: state.getIn(['sessions', 'eventsIndex']),
|
|
}),
|
|
{
|
|
setEventFilter,
|
|
filterOutNote,
|
|
}
|
|
)(observer(EventsBlock));
|