* start moving ui to redux tlk * remove unused reducer * changes for gdpr and site types * ui: migrating duck/roles to mobx * ui: drop unreferenced types * ui: drop unreferenced types * ui: move player slice reducer to mobx family * ui: move assignments to issueReportingStore.ts * remove issues store * some fixes after issues store * remove errors reducer, drop old components * finish removing errors reducer * start moving integrations state to mobx * change(ui): funnel duck cleanup * change(ui): custom fields * change(ui): customMetrics cleanup * change(ui): customMetrics cleanup * change(ui): duck/filters minor cleanup * change(ui): duck/filters cleanup * change(ui): duck/customMetrics cleanup and upgrades * fix integrations service, fix babel config to >.25 + not ie * refactoring integrations reducers etc WIP * finish removing integrations state * some fixes for integrated check * start of projects refactoring * move api and "few" files to new project store * new batch for site -> projects * fix setid context * move all critical components, drop site duck * remove all duck/site refs, remove old components * fixup for SessionTags.tsx, remove duck/sources (?) * move session store * init sessionstore outside of context * fix userfilter * replace simple actions for session store * sessions sotre * Rtm temp (#2597) * change(ui): duck/search wip * change(ui): duck/search wip * change(ui): duck/search wip * change(ui): duck/searchLive wip * change(ui): duck/searchLive wip * change(ui): duck/searchLive wip * change(ui): duck/searchLive wip * change(ui): search states * change(ui): search states * change(ui): search states * change(ui): fix savedSearch store * change(ui): fix savedSearch store * some fixes for session connector * change(ui): fix savedSearch store * change(ui): fix searchLive * change(ui): fix searchLive * fixes for session replay * change(ui): bookmark fetch * last components for sessions * add fetchautoplaylist * finish session reducer, remove deleted reducers * change(ui): fix the search fetch * change(ui): fix the search fetch * fix integrations call ctx * ensure ctx for sessionstore * fix(ui): checking for latest sessions path * start removing user reducer * removing user reducer pt2... * finish user store * remove rand log * fix crashes * tinkering workflow file for tracker test * making sure prefetched sessions work properly * fix conflict * fix router redirects during loading --------- Co-authored-by: Shekar Siri <sshekarsiri@gmail.com>
101 lines
3.2 KiB
TypeScript
101 lines
3.2 KiB
TypeScript
import React from 'react';
|
|
import { withRouter } from 'react-router-dom';
|
|
import { sessions as sessionsRoute, withSiteId } from 'App/routes';
|
|
import { BackLink } from 'UI';
|
|
import cn from 'classnames';
|
|
import SessionMetaList from 'Shared/SessionItem/SessionMetaList';
|
|
import UserCard from '../ReplayPlayer/EventsBlock/UserCard';
|
|
import Tabs from 'Components/Session/Tabs';
|
|
import { PlayerContext } from 'App/components/Session/playerContext';
|
|
import { observer } from 'mobx-react-lite';
|
|
import stl from '../ReplayPlayer/playerBlockHeader.module.css';
|
|
import { IFRAME } from 'App/constants/storageKeys';
|
|
import { useStore } from 'App/mstore';
|
|
|
|
const SESSIONS_ROUTE = sessionsRoute();
|
|
|
|
// TODO props
|
|
function PlayerBlockHeader(props: any) {
|
|
const [hideBack, setHideBack] = React.useState(false);
|
|
const { player, store } = React.useContext(PlayerContext);
|
|
|
|
const playerState = store?.get?.() || { width: 0, height: 0, showEvents: false };
|
|
const { width = 0, height = 0, showEvents = false } = playerState;
|
|
const { customFieldStore, projectsStore, sessionStore } = useStore();
|
|
const session = sessionStore.current;
|
|
const siteId = projectsStore.siteId!;
|
|
const {
|
|
fullscreen,
|
|
setActiveTab,
|
|
activeTab,
|
|
history,
|
|
} = props;
|
|
const metaList = customFieldStore.list.map((i: any) => i.key)
|
|
|
|
React.useEffect(() => {
|
|
const iframe = localStorage.getItem(IFRAME) || false;
|
|
setHideBack(!!iframe && iframe === 'true');
|
|
|
|
if (metaList.length === 0) customFieldStore.fetchList();
|
|
}, []);
|
|
|
|
const backHandler = () => {
|
|
history.push(withSiteId(SESSIONS_ROUTE, siteId));
|
|
};
|
|
|
|
const { metadata } = session;
|
|
let _metaList = Object.keys(metadata || {})
|
|
.filter((i) => metaList.includes(i))
|
|
.map((key) => {
|
|
const value = metadata[key];
|
|
return { label: key, value };
|
|
});
|
|
|
|
const TABS = Object.keys(props.tabs).map((tab) => ({
|
|
text: props.tabs[tab],
|
|
key: tab,
|
|
}));
|
|
|
|
return (
|
|
<div className={cn(stl.header, 'flex justify-between', { hidden: fullscreen })}>
|
|
<div className="flex w-full items-center">
|
|
{!hideBack && (
|
|
<div className="flex items-center h-full cursor-pointer group" onClick={backHandler}>
|
|
{/* @ts-ignore TODO */}
|
|
<BackLink label="Back" className="h-full ml-2" />
|
|
<div className={stl.divider} />
|
|
</div>
|
|
)}
|
|
<UserCard className="" width={width} height={height} />
|
|
|
|
<div className={cn('ml-auto flex items-center h-full')}>
|
|
{_metaList.length > 0 && (
|
|
<div className="border-l h-full flex items-center px-2">
|
|
<SessionMetaList className="" metaList={_metaList} maxLength={2} />
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
<div className="relative border-l" style={{ minWidth: '270px' }}>
|
|
<Tabs
|
|
tabs={TABS}
|
|
active={activeTab}
|
|
onClick={(tab) => {
|
|
if (activeTab === tab) {
|
|
setActiveTab('');
|
|
player.toggleEvents();
|
|
} else {
|
|
setActiveTab(tab);
|
|
!showEvents && player.toggleEvents();
|
|
}
|
|
}}
|
|
border={false}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const PlayerHeaderCont = observer(PlayerBlockHeader);
|
|
|
|
export default withRouter(PlayerHeaderCont);
|