diff --git a/frontend/.prettierrc b/frontend/.prettierrc index 5a938ce18..761a3e639 100644 --- a/frontend/.prettierrc +++ b/frontend/.prettierrc @@ -1,4 +1,6 @@ { "tabWidth": 4, - "useTabs": false + "useTabs": false, + "printWidth": 150, + "singleQuote": true } diff --git a/frontend/app/components/Session_/PlayerBlockHeader.js b/frontend/app/components/Session_/PlayerBlockHeader.js index d652ed2ec..f0576e419 100644 --- a/frontend/app/components/Session_/PlayerBlockHeader.js +++ b/frontend/app/components/Session_/PlayerBlockHeader.js @@ -17,132 +17,148 @@ import AssistTabs from '../Assist/components/AssistTabs'; const SESSIONS_ROUTE = sessionsRoute(); const ASSIST_ROUTE = assistRoute(); -@connectPlayer(state => ({ - width: state.width, - height: state.height, - live: state.live, - loading: state.cssLoading || state.messagesLoading, - showEvents: state.showEvents, -}), { toggleEvents }) -@connect((state, props) => { - const isAssist = window.location.pathname.includes('/assist/'); - const session = state.getIn([ 'sessions', 'current' ]); +@connectPlayer( + (state) => ({ + width: state.width, + height: state.height, + live: state.live, + loading: state.cssLoading || state.messagesLoading, + showEvents: state.showEvents, + }), + { toggleEvents } +) +@connect( + (state, props) => { + const isAssist = window.location.pathname.includes('/assist/'); + const session = state.getIn(['sessions', 'current']); - return { - isAssist, - session, - sessionPath: state.getIn([ 'sessions', 'sessionPath' ]), - loading: state.getIn([ 'sessions', 'toggleFavoriteRequest', 'loading' ]), - disabled: state.getIn([ 'components', 'targetDefiner', 'inspectorMode' ]) || props.loading, - local: state.getIn(['sessions', 'timezone']), - funnelRef: state.getIn(['funnels', 'navRef']), - siteId: state.getIn([ 'site', 'siteId' ]), - metaList: state.getIn(['customFields', 'list']).map(i => i.key), - closedLive: !!state.getIn([ 'sessions', 'errors' ]) || (isAssist && !session.live), - } -}, { - toggleFavorite, setSessionPath -}) + return { + isAssist, + session, + sessionPath: state.getIn(['sessions', 'sessionPath']), + loading: state.getIn(['sessions', 'toggleFavoriteRequest', 'loading']), + disabled: state.getIn(['components', 'targetDefiner', 'inspectorMode']) || props.loading, + local: state.getIn(['sessions', 'timezone']), + funnelRef: state.getIn(['funnels', 'navRef']), + siteId: state.getIn(['site', 'siteId']), + metaList: state.getIn(['customFields', 'list']).map((i) => i.key), + closedLive: !!state.getIn(['sessions', 'errors']) || (isAssist && !session.live), + }; + }, + { + toggleFavorite, + setSessionPath, + } +) @withRouter export default class PlayerBlockHeader extends React.PureComponent { - getDimension = (width, height) => { - return width && height ? ( -
- { width || 'x' } { height || 'x' } -
- ) : Resolution N/A; - } + state = { + hideBack: false, + }; - backHandler = () => { - const { history, siteId, sessionPath, isAssist } = this.props; - if (sessionPath.pathname === history.location.pathname || sessionPath.pathname.includes("/session/") || isAssist) { - history.push(withSiteId(isAssist ? ASSIST_ROUTE: SESSIONS_ROUTE, siteId)); - } else { - history.push(sessionPath ? sessionPath.pathname + sessionPath.search : withSiteId(SESSIONS_ROUTE, siteId)); + componentDidMount() { + const { location } = this.props; + const queryParams = new URLSearchParams(location.search); + this.setState({ hideBack: queryParams.has('iframe') && queryParams.get('iframe') === 'true' }); } - } - toggleFavorite = () => { - const { session } = this.props; - this.props.toggleFavorite(session.sessionId); - } + getDimension = (width, height) => { + return width && height ? ( +
+ {width || 'x'} {height || 'x'} +
+ ) : ( + Resolution N/A + ); + }; - render() { - const { - width, - height, - session, - fullscreen, - metaList, - closedLive = false, - siteId, - isAssist, - setActiveTab, - activeTab, - showEvents, - toggleEvents, - } = this.props; - // const _live = isAssist; + backHandler = () => { + const { history, siteId, sessionPath, isAssist } = this.props; + if (sessionPath.pathname === history.location.pathname || sessionPath.pathname.includes('/session/') || isAssist) { + history.push(withSiteId(isAssist ? ASSIST_ROUTE : SESSIONS_ROUTE, siteId)); + } else { + history.push(sessionPath ? sessionPath.pathname + sessionPath.search : withSiteId(SESSIONS_ROUTE, siteId)); + } + }; - const { - sessionId, - userId, - userNumericHash, - live, - metadata, - } = session; - let _metaList = Object.keys(metadata).filter(i => metaList.includes(i)).map(key => { - const value = metadata[key]; - return { label: key, value }; - }); + toggleFavorite = () => { + const { session } = this.props; + this.props.toggleFavorite(session.sessionId); + }; - const TABS = [ this.props.tabs.EVENTS, this.props.tabs.HEATMAPS ].map(tab => ({ text: tab, key: tab })); - return ( -
-
-
- -
-
- - { isAssist && } + render() { + const { + width, + height, + session, + fullscreen, + metaList, + closedLive = false, + siteId, + isAssist, + setActiveTab, + activeTab, + showEvents, + toggleEvents, + } = this.props; + // const _live = isAssist; -
- { live && !isAssist && ( - <> -
- - This Session is Now Continuing Live - + const { hideBack } = this.state; + + const { sessionId, userId, userNumericHash, live, metadata } = session; + let _metaList = Object.keys(metadata) + .filter((i) => metaList.includes(i)) + .map((key) => { + const value = metadata[key]; + return { label: key, value }; + }); + + const TABS = [this.props.tabs.EVENTS, this.props.tabs.HEATMAPS].map((tab) => ({ text: tab, key: tab })); + return ( +
+
+ {!hideBack && ( +
+ +
+
+ )} + + {isAssist && } + +
+ {live && !isAssist && ( + <> +
+ This Session is Now Continuing Live +
+ {_metaList.length > 0 &&
} + + )} + + {_metaList.length > 0 && ( +
+ +
+ )} + + {isAssist && } +
- {_metaList.length > 0 &&
} - - )} - - {_metaList.length > 0 && ( -
- -
- )} - - { isAssist && } -
-
- {!isAssist && ( -
- { setActiveTab(tab); !showEvents && toggleEvents(true) } } - border={ false } - /> -
- )} -
- ); - } + {!isAssist && ( +
+ { + setActiveTab(tab); + !showEvents && toggleEvents(true); + }} + border={false} + /> +
+ )} +
+ ); + } }