import { useStore } from 'App/mstore'; import SummaryBlock from "Components/Session/Player/ReplayPlayer/SummaryBlock"; import React, { useMemo } from 'react'; import { Icon, Tooltip } from 'UI'; import QueueControls from 'App/components/Session_/QueueControls'; import Bookmark from 'Shared/Bookmark'; import SharePopup from 'Shared/SharePopup/SharePopup'; import Issues from 'App/components/Session_/Issues/Issues'; import NotePopup from 'App/components/Session_/components/NotePopup'; import ItemMenu from 'App/components/Session_/components/HeaderMenu'; import { useModal } from 'App/components/Modal'; import BugReportModal from 'App/components/Session_/BugReport/BugReportModal'; import { PlayerContext } from 'App/components/Session/playerContext'; import { observer } from 'mobx-react-lite'; import AutoplayToggle from 'Shared/AutoplayToggle'; import { connect } from 'react-redux'; import SessionTabs from 'Components/Session/Player/SharedComponents/SessionTabs'; import { IFRAME } from 'App/constants/storageKeys'; import cn from 'classnames'; import { Switch } from 'antd'; const localhostWarn = (project: string): string => project + '_localhost_warn'; const disableDevtools = 'or_devtools_uxt_toggle'; function SubHeader(props: any) { const localhostWarnKey = localhostWarn(props.siteId); const defaultLocalhostWarn = localStorage.getItem(localhostWarnKey) !== '1'; const [showWarningModal, setWarning] = React.useState(defaultLocalhostWarn); const { player, store } = React.useContext(PlayerContext); const { width, height, endTime, location: currentLocation = 'loading...' } = store.get(); const hasIframe = localStorage.getItem(IFRAME) === 'true'; const { uxtestingStore } = useStore(); const enabledIntegration = useMemo(() => { const { integrations } = props; if (!integrations || !integrations.size) { return false; } return integrations.some((i: Record) => i.token); }, [props.integrations]); const { showModal, hideModal } = useModal(); const location = currentLocation && currentLocation.length > 70 ? `${currentLocation.slice(0, 25)}...${currentLocation.slice(-40)}` : currentLocation; const showReportModal = () => { const { tabStates, currentTab } = store.get(); const resourceList = tabStates[currentTab]?.resourceList || []; const exceptionsList = tabStates[currentTab]?.exceptionsList || []; const eventsList = tabStates[currentTab]?.eventList || []; const graphqlList = tabStates[currentTab]?.graphqlList || []; const fetchList = tabStates[currentTab]?.fetchList || []; const mappedResourceList = resourceList .filter((r) => r.isRed || r.isYellow) // @ts-ignore .concat(fetchList.filter((i) => parseInt(i.status) >= 400)) // @ts-ignore .concat(graphqlList.filter((i) => parseInt(i.status) >= 400)); player.pause(); const xrayProps = { currentLocation: currentLocation, resourceList: mappedResourceList, exceptionsList: exceptionsList, eventsList: eventsList, endTime: endTime, }; showModal( // @ts-ignore , { right: true, width: 620 } ); }; const showSummary = () => { player.pause(); showModal(, { right: true, width: 330 }) } const showWarning = location && /(localhost)|(127.0.0.1)|(0.0.0.0)/.test(location) && showWarningModal; const closeWarning = () => { localStorage.setItem(localhostWarnKey, '1'); setWarning(false); }; const toggleDevtools = (enabled: boolean): void => { localStorage.setItem(disableDevtools, enabled ? '0' : '1'); uxtestingStore.setHideDevtools(!enabled); }; const additionalMenu = [ { key: 1, component: , }, { key: 2, component: , }, { key: 3, component: (
Create Bug Report
), }, { key: 4, autoclose: true, component: (
Share
} /> ), }, ]; if (enabledIntegration) { additionalMenu.push({ key: 5, component: , }); } return ( <>
{showWarning ? (
Some assets may load incorrectly on localhost. Learn More
) : null}
{uxtestingStore.isUxt() ? ( ) : (
{/* @ts-ignore */}
)}
{location && ( )} ); } export default connect((state: Record) => ({ siteId: state.getIn(['site', 'siteId']), integrations: state.getIn(['issues', 'list']), modules: state.getIn(['user', 'account', 'modules']) || [], }))(observer(SubHeader));