import { connect } from 'react-redux'; import { withRouter } from 'react-router-dom'; import { browserIcon, osIcon, deviceTypeIcon } from 'App/iconNames'; import { formatTimeOrDate } from 'App/date'; import { sessions as sessionsRoute, funnel as funnelRoute, funnelIssue as funnelIssueRoute, withSiteId } from 'App/routes'; import { Icon, CountryFlag, IconButton, BackLink } from 'UI'; import { toggleFavorite } from 'Duck/sessions'; import cn from 'classnames'; import { connectPlayer } from 'Player'; import HeaderInfo from './HeaderInfo'; import SharePopup from '../shared/SharePopup/SharePopup'; import { fetchList as fetchListIntegration } from 'Duck/integrations/actions'; import cls from './playerBlockHeader.css'; import Issues from './Issues/Issues'; import Autoplay from './Autoplay'; import AssistActions from '../Assist/components/AssistActions'; const SESSIONS_ROUTE = sessionsRoute(); function capitalise(str) { return str[0].toUpperCase() + str.slice(1); } @connectPlayer(state => ({ width: state.width, height: state.height, live: state.live, loading: state.cssLoading || state.messagesLoading, })) @connect((state, props) => ({ session: state.getIn([ 'sessions', 'current' ]), loading: state.getIn([ 'sessions', 'toggleFavoriteRequest', 'loading' ]), disabled: state.getIn([ 'components', 'targetDefiner', 'inspectorMode' ]) || props.loading, jiraConfig: state.getIn([ 'issues', 'list' ]).first(), issuesFetched: state.getIn([ 'issues', 'issuesFetched' ]), local: state.getIn(['sessions', 'timezone']), funnelRef: state.getIn(['funnels', 'navRef']), siteId: state.getIn([ 'user', 'siteId' ]), funnelPage: state.getIn(['sessions', 'funnelPage']), }), { toggleFavorite, fetchListIntegration }) @withRouter export default class PlayerBlockHeader extends React.PureComponent { componentDidMount() { if (!this.props.issuesFetched) this.props.fetchListIntegration('issues') } getDimension = (width, height) => (
{ width || 'x' } { height || 'x' }
); backHandler = () => { const { history, siteId, funnelPage } = this.props; const funnelId = funnelPage && funnelPage.get('funnelId'); const issueId = funnelPage && funnelPage.get('issueId'); if (funnelId || issueId) { if (issueId) { history.push(withSiteId(funnelIssueRoute(funnelId, issueId), siteId)) } else history.push(withSiteId(funnelRoute(funnelId), siteId)); } else history.push(withSiteId(SESSIONS_ROUTE), siteId); } toggleFavorite = () => { const { session } = this.props; this.props.toggleFavorite(session.sessionId); } render() { const { width, height, session: { sessionId, userCountry, userId, favorite, startedAt, userBrowser, userOs, userDevice, userBrowserVersion, userDeviceType, }, loading, live, disabled, jiraConfig, fullscreen, } = this.props; const { history, siteId } = this.props; return (
{ formatTimeOrDate(startedAt) } { this.props.local === 'UTC' ? 'UTC' : ''}
{ live && } { !live && ( <>
} /> )} { !live && jiraConfig && jiraConfig.token && }
); } }