import React from 'react'; import { Icon, Tooltip, Button } from 'UI'; import QueueControls from './QueueControls'; import Bookmark from 'Shared/Bookmark'; import SharePopup from '../shared/SharePopup/SharePopup'; import copy from 'copy-to-clipboard'; import Issues from './Issues/Issues'; import NotePopup from './components/NotePopup'; import ItemMenu from './components/HeaderMenu'; import { useModal } from 'App/components/Modal'; import BugReportModal from './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' const localhostWarn = (project) => project + '_localhost_warn' function SubHeader(props) { 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, location: currentLocation, fetchList, graphqlList, resourceList, exceptionsList, eventList: eventsList, endTime, } = store.get(); const mappedResourceList = resourceList .filter((r) => r.isRed || r.isYellow) .concat(fetchList.filter((i) => parseInt(i.status) >= 400)) .concat(graphqlList.filter((i) => parseInt(i.status) >= 400)); const [isCopied, setCopied] = React.useState(false); const { showModal, hideModal } = useModal(); const location = currentLocation && currentLocation.length > 70 ? `${currentLocation.slice(0, 25)}...${currentLocation.slice(-40)}` : currentLocation; const showReportModal = () => { player.pause(); const xrayProps = { currentLocation: currentLocation, resourceList: mappedResourceList, exceptionsList: exceptionsList, eventsList: eventsList, endTime: endTime, }; showModal( , { right: true, width: 620 } ); }; const showWarning = location && /(localhost)|(127.0.0.1)|(0.0.0.0)/.test(location) && showWarningModal; const closeWarning = () => { localStorage.setItem(localhostWarnKey, '1') setWarning(false) } return (
{showWarning ? (
Some assets may load incorrectly on localhost. Learn More
) : null} {location && ( <>
{ copy(currentLocation); setCopied(true); setTimeout(() => setCopied(false), 5000); }} > {location}
)}
} /> , }, { key: 2, component: , }, ]} />
); } export default connect((state) => ({ siteId: state.getIn(['site', 'siteId']) }))(observer(SubHeader));