* 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>
342 lines
11 KiB
TypeScript
342 lines
11 KiB
TypeScript
import React from 'react';
|
|
import cn from 'classnames';
|
|
import { connect } from 'react-redux';
|
|
import { selectStorageType, STORAGE_TYPES, StorageType } from 'Player';
|
|
import { PlayButton, PlayingState, FullScreenButton } from 'App/player-ui'
|
|
|
|
import { Icon, Tooltip } from 'UI';
|
|
import {
|
|
CONSOLE,
|
|
fullscreenOff,
|
|
fullscreenOn,
|
|
GRAPHQL,
|
|
INSPECTOR,
|
|
NETWORK,
|
|
OVERVIEW,
|
|
PERFORMANCE,
|
|
PROFILER,
|
|
STACKEVENTS,
|
|
STORAGE,
|
|
toggleBottomBlock,
|
|
changeSkipInterval,
|
|
} from 'Duck/components/player';
|
|
import { PlayerContext } from 'App/components/Session/playerContext';
|
|
import { observer } from 'mobx-react-lite';
|
|
import { fetchSessions } from 'Duck/liveSearch';
|
|
|
|
import Timeline from './Timeline';
|
|
import ControlButton from './ControlButton';
|
|
import PlayerControls from './components/PlayerControls';
|
|
|
|
import styles from './controls.module.css';
|
|
import XRayButton from 'Shared/XRayButton';
|
|
import CreateNote from 'Components/Session_/Player/Controls/components/CreateNote';
|
|
|
|
export const SKIP_INTERVALS = {
|
|
2: 2e3,
|
|
5: 5e3,
|
|
10: 1e4,
|
|
15: 15e3,
|
|
20: 2e4,
|
|
30: 3e4,
|
|
60: 6e4,
|
|
};
|
|
|
|
function getStorageName(type: any) {
|
|
switch (type) {
|
|
case STORAGE_TYPES.REDUX:
|
|
return 'REDUX';
|
|
case STORAGE_TYPES.MOBX:
|
|
return 'MOBX';
|
|
case STORAGE_TYPES.VUEX:
|
|
return 'VUEX';
|
|
case STORAGE_TYPES.NGRX:
|
|
return 'NGRX';
|
|
case STORAGE_TYPES.ZUSTAND:
|
|
return 'ZUSTAND';
|
|
case STORAGE_TYPES.NONE:
|
|
return 'STATE';
|
|
}
|
|
}
|
|
|
|
function Controls(props: any) {
|
|
const { player, store } = React.useContext(PlayerContext);
|
|
|
|
const {
|
|
playing,
|
|
completed,
|
|
skip,
|
|
speed,
|
|
messagesLoading,
|
|
inspectorMode,
|
|
markedTargets,
|
|
currentTab,
|
|
tabStates
|
|
} = store.get();
|
|
|
|
const cssLoading = tabStates[currentTab]?.cssLoading ?? false;
|
|
const profilesList = tabStates[currentTab]?.profilesList || [];
|
|
const graphqlList = tabStates[currentTab]?.graphqlList || [];
|
|
const logRedCount = tabStates[currentTab]?.logMarkedCountNow || 0;
|
|
const resourceRedCount = tabStates[currentTab]?.resourceMarkedCountNow || 0;
|
|
const stackRedCount = tabStates[currentTab]?.stackMarkedCountNow || 0;
|
|
const exceptionsList = tabStates[currentTab]?.exceptionsList || [];
|
|
|
|
const {
|
|
bottomBlock,
|
|
toggleBottomBlock,
|
|
fullscreen,
|
|
changeSkipInterval,
|
|
skipInterval,
|
|
disabledRedux,
|
|
showStorageRedux,
|
|
session,
|
|
} = props;
|
|
|
|
const storageType = store.get().tabStates[currentTab] ? selectStorageType(store.get().tabStates[currentTab]) : StorageType.NONE
|
|
const disabled = disabledRedux || cssLoading || messagesLoading || inspectorMode || markedTargets;
|
|
const profilesCount = profilesList.length;
|
|
const graphqlCount = graphqlList.length;
|
|
const showGraphql = graphqlCount > 0;
|
|
const showProfiler = profilesCount > 0;
|
|
const showExceptions = exceptionsList.length > 0;
|
|
const showStorage = storageType !== STORAGE_TYPES.NONE || showStorageRedux;
|
|
|
|
const onKeyDown = (e: any) => {
|
|
if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {
|
|
return;
|
|
}
|
|
if (inspectorMode) {
|
|
if (e.key === 'Esc' || e.key === 'Escape') {
|
|
player.toggleInspectorMode(false);
|
|
}
|
|
}
|
|
if (e.key === 'Esc' || e.key === 'Escape') {
|
|
props.fullscreenOff();
|
|
}
|
|
if (e.key === 'ArrowRight') {
|
|
forthTenSeconds();
|
|
}
|
|
if (e.key === 'ArrowLeft') {
|
|
backTenSeconds();
|
|
}
|
|
if (e.key === 'ArrowDown') {
|
|
player.speedDown();
|
|
}
|
|
if (e.key === 'ArrowUp') {
|
|
player.speedUp();
|
|
}
|
|
};
|
|
|
|
React.useEffect(() => {
|
|
document.addEventListener('keydown', onKeyDown.bind(this));
|
|
return () => {
|
|
document.removeEventListener('keydown', onKeyDown.bind(this));
|
|
};
|
|
}, []);
|
|
|
|
const forthTenSeconds = () => {
|
|
// @ts-ignore
|
|
player.jumpInterval(SKIP_INTERVALS[skipInterval]);
|
|
};
|
|
|
|
const backTenSeconds = () => {
|
|
// @ts-ignore
|
|
player.jumpInterval(-SKIP_INTERVALS[skipInterval]);
|
|
};
|
|
|
|
const toggleBottomTools = (blockName: number) => {
|
|
if (blockName === INSPECTOR) {
|
|
// player.toggleInspectorMode(false);
|
|
bottomBlock && toggleBottomBlock();
|
|
} else {
|
|
// player.toggleInspectorMode(false);
|
|
toggleBottomBlock(blockName);
|
|
}
|
|
};
|
|
|
|
const state = completed ? PlayingState.Completed : playing ? PlayingState.Playing : PlayingState.Paused
|
|
|
|
return (
|
|
<div className={styles.controls}>
|
|
<Timeline />
|
|
<CreateNote />
|
|
{!fullscreen && (
|
|
<div className={cn(styles.buttons, '!px-2')}>
|
|
<div className="flex items-center">
|
|
<PlayerControls
|
|
skip={skip}
|
|
speed={speed}
|
|
disabled={disabled}
|
|
backTenSeconds={backTenSeconds}
|
|
forthTenSeconds={forthTenSeconds}
|
|
toggleSpeed={(speedIndex) => player.toggleSpeed(speedIndex)}
|
|
toggleSkip={() => player.toggleSkip()}
|
|
playButton={<PlayButton state={state} togglePlay={player.togglePlay} iconSize={36} />}
|
|
skipIntervals={SKIP_INTERVALS}
|
|
setSkipInterval={changeSkipInterval}
|
|
currentInterval={skipInterval}
|
|
startedAt={session.startedAt}
|
|
/>
|
|
<div className={cn('mx-2')} />
|
|
<XRayButton
|
|
isActive={bottomBlock === OVERVIEW && !inspectorMode}
|
|
onClick={() => toggleBottomTools(OVERVIEW)}
|
|
/>
|
|
</div>
|
|
|
|
<div className="flex items-center h-full">
|
|
<ControlButton
|
|
disabled={disabled && !inspectorMode}
|
|
onClick={() => toggleBottomTools(CONSOLE)}
|
|
active={bottomBlock === CONSOLE && !inspectorMode}
|
|
label="CONSOLE"
|
|
noIcon
|
|
labelClassName="!text-base font-semibold"
|
|
hasErrors={logRedCount > 0 || showExceptions}
|
|
containerClassName="mx-2"
|
|
/>
|
|
|
|
<ControlButton
|
|
disabled={disabled && !inspectorMode}
|
|
onClick={() => toggleBottomTools(NETWORK)}
|
|
active={bottomBlock === NETWORK && !inspectorMode}
|
|
label="NETWORK"
|
|
hasErrors={resourceRedCount > 0}
|
|
noIcon
|
|
labelClassName="!text-base font-semibold"
|
|
containerClassName="mx-2"
|
|
/>
|
|
|
|
<ControlButton
|
|
disabled={disabled && !inspectorMode}
|
|
onClick={() => toggleBottomTools(PERFORMANCE)}
|
|
active={bottomBlock === PERFORMANCE && !inspectorMode}
|
|
label="PERFORMANCE"
|
|
noIcon
|
|
labelClassName="!text-base font-semibold"
|
|
containerClassName="mx-2"
|
|
/>
|
|
|
|
{showGraphql && (
|
|
<ControlButton
|
|
disabled={disabled && !inspectorMode}
|
|
onClick={() => toggleBottomTools(GRAPHQL)}
|
|
active={bottomBlock === GRAPHQL && !inspectorMode}
|
|
label="GRAPHQL"
|
|
noIcon
|
|
labelClassName="!text-base font-semibold"
|
|
containerClassName="mx-2"
|
|
/>
|
|
)}
|
|
|
|
{showStorage && (
|
|
<ControlButton
|
|
disabled={disabled && !inspectorMode}
|
|
onClick={() => toggleBottomTools(STORAGE)}
|
|
active={bottomBlock === STORAGE && !inspectorMode}
|
|
label={getStorageName(storageType)}
|
|
noIcon
|
|
labelClassName="!text-base font-semibold"
|
|
containerClassName="mx-2"
|
|
/>
|
|
)}
|
|
<ControlButton
|
|
disabled={disabled && !inspectorMode}
|
|
onClick={() => toggleBottomTools(STACKEVENTS)}
|
|
active={bottomBlock === STACKEVENTS && !inspectorMode}
|
|
label="EVENTS"
|
|
noIcon
|
|
labelClassName="!text-base font-semibold"
|
|
containerClassName="mx-2"
|
|
hasErrors={stackRedCount > 0}
|
|
/>
|
|
{showProfiler && (
|
|
<ControlButton
|
|
disabled={disabled && !inspectorMode}
|
|
onClick={() => toggleBottomTools(PROFILER)}
|
|
active={bottomBlock === PROFILER && !inspectorMode}
|
|
label="PROFILER"
|
|
noIcon
|
|
labelClassName="!text-base font-semibold"
|
|
containerClassName="mx-2"
|
|
/>
|
|
)}
|
|
|
|
<Tooltip title="Fullscreen" delay={0} placement="top-start" className="mx-4">
|
|
<FullScreenButton
|
|
size={16}
|
|
onClick={props.fullscreenOn}
|
|
customClasses={'rounded hover:bg-gray-light-shade color-gray-medium'}
|
|
/>
|
|
</Tooltip>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const ControlPlayer = observer(Controls);
|
|
|
|
export default connect(
|
|
(state: any) => {
|
|
const permissions = state.getIn(['user', 'account', 'permissions']) || [];
|
|
const isEnterprise = state.getIn(['user', 'account', 'edition']) === 'ee';
|
|
return {
|
|
disabledRedux: isEnterprise && !permissions.includes('DEV_TOOLS'),
|
|
fullscreen: state.getIn(['components', 'player', 'fullscreen']),
|
|
bottomBlock: state.getIn(['components', 'player', 'bottomBlock']),
|
|
showStorageRedux: !state.getIn(['components', 'player', 'hiddenHints', 'storage']),
|
|
showStackRedux: !state.getIn(['components', 'player', 'hiddenHints', 'stack']),
|
|
session: state.getIn(['sessions', 'current']),
|
|
totalAssistSessions: state.getIn(['liveSearch', 'total']),
|
|
skipInterval: state.getIn(['components', 'player', 'skipInterval']),
|
|
};
|
|
},
|
|
{
|
|
fullscreenOn,
|
|
fullscreenOff,
|
|
toggleBottomBlock,
|
|
fetchSessions,
|
|
changeSkipInterval,
|
|
}
|
|
)(ControlPlayer);
|
|
|
|
// shouldComponentUpdate(nextProps) {
|
|
// if (
|
|
// nextProps.fullscreen !== props.fullscreen ||
|
|
// nextProps.bottomBlock !== props.bottomBlock ||
|
|
// nextProps.live !== props.live ||
|
|
// nextProps.livePlay !== props.livePlay ||
|
|
// nextProps.playing !== props.playing ||
|
|
// nextProps.completed !== props.completed ||
|
|
// nextProps.skip !== props.skip ||
|
|
// nextProps.skipToIssue !== props.skipToIssue ||
|
|
// nextProps.speed !== props.speed ||
|
|
// nextProps.disabled !== props.disabled ||
|
|
// nextProps.fullscreenDisabled !== props.fullscreenDisabled ||
|
|
// // nextProps.inspectorMode !== props.inspectorMode ||
|
|
// // nextProps.logCount !== props.logCount ||
|
|
// nextProps.logRedCount !== props.logRedCount ||
|
|
// nextProps.showExceptions !== props.showExceptions ||
|
|
// nextProps.resourceRedCount !== props.resourceRedCount ||
|
|
// nextProps.fetchRedCount !== props.fetchRedCount ||
|
|
// nextProps.showStack !== props.showStack ||
|
|
// nextProps.stackCount !== props.stackCount ||
|
|
// nextProps.stackRedCount !== props.stackRedCount ||
|
|
// nextProps.profilesCount !== props.profilesCount ||
|
|
// nextProps.storageCount !== props.storageCount ||
|
|
// nextProps.storageType !== props.storageType ||
|
|
// nextProps.showStorage !== props.showStorage ||
|
|
// nextProps.showProfiler !== props.showProfiler ||
|
|
// nextProps.showGraphql !== props.showGraphql ||
|
|
// nextProps.showFetch !== props.showFetch ||
|
|
// nextProps.fetchCount !== props.fetchCount ||
|
|
// nextProps.graphqlCount !== props.graphqlCount ||
|
|
// nextProps.liveTimeTravel !== props.liveTimeTravel ||
|
|
// nextProps.skipInterval !== props.skipInterval
|
|
// )
|
|
// return true;
|
|
// return false;
|
|
// }
|