import * as React from 'react'; import 'cbioportal-frontend-commons/dist/styles.css'; import '../../globalStyles/prefixed-global.scss'; import PortalHeader from './PortalHeader'; import { getBrowserWindow, isWebdriver } from 'cbioportal-frontend-commons'; import { observer } from 'mobx-react'; import { getServerConfig } from 'config/config'; import Helmet from 'react-helmet'; import { If, Else, Then } from 'react-if'; import UserMessager from 'shared/components/userMessager/UserMessage'; import { formatErrorLog, formatErrorTitle, formatErrorMessages, } from 'shared/lib/errorFormatter'; import { buildCBioPortalPageUrl } from 'shared/api/urls'; import ErrorScreen from 'shared/components/errorScreen/ErrorScreen'; import { ServerConfigHelpers } from 'config/config'; import { shouldShowStudyViewWarning, StudyAgreement, } from 'appShell/App/usageAgreements/StudyAgreement'; import { GenieAgreement, shouldShowGenieWarning, } from 'appShell/App/usageAgreements/GenieAgreement'; import makeRoutes from 'routes'; import { AppContext } from 'cbioportal-frontend-commons'; import { IAppContext } from 'cbioportal-frontend-commons'; import { ErrorAlert } from 'shared/components/errorScreen/ErrorAlert'; import { ErrorInfo } from 'react'; import { observable } from 'mobx'; import { sendToLoggly } from 'shared/lib/tracking'; interface IContainerProps { location: Location; children: React.ReactNode; } function isLocalDBServer() { try { return getServerConfig().app_name === 'localdbe2e'; } catch (ex) { return false; } } @observer export default class Container extends React.Component { private get routingStore() { return getBrowserWindow().routingStore; } private get appStore() { return getBrowserWindow().globalStores.appStore; } renderChildren() { const childProps = { ...this.props }; const { children } = this.props; return React.Children.map(children, c => React.cloneElement(c as React.ReactElement, childProps) ); } get appContext(): IAppContext { return { showDownloadControls: !getServerConfig() .skin_hide_download_controls, }; } render() { if ( !isLocalDBServer() && !isWebdriver() && !ServerConfigHelpers.sessionServiceIsEnabled() ) { return (
As of version 3.0.0, all cBioPortal installations require a session service. Please review these instructions for how to do so.{' '} https://docs.cbioportal.org/2.1.2-deploy-without-docker/deploying#run-cbioportal-session-service

} />
); } return (
{getServerConfig().skin_title}
{shouldShowStudyViewWarning() && } {shouldShowGenieWarning() && }
Return to homepage } errorLog={formatErrorLog( this.appStore.siteErrors )} errorMessages={formatErrorMessages( this.appStore.siteErrors )} />
{makeRoutes()}
); } } class ErrorBoundary extends React.Component< any, { hasError: boolean; error?: Error } > { @observable hasError = false; constructor(props: any) { super(props); this.state = { hasError: false, }; } static getDerivedStateFromError(error: any) { // Update state so the next render will show the fallback UI. return { hasError: true, error }; } componentDidCatch(error: Error, errorInfo: ErrorInfo) { // You can also log the error to an error reporting service sendToLoggly({ message: error.message, tag: 'ERROR_JS' }); this.hasError = true; } render() { if (this.state.hasError) { // fallback UI return ( ); } else { return this.props.children; } } }