import * as React from 'react'; import _ from 'lodash'; import { getBrowserWindow } from 'cbioportal-frontend-commons'; import { observer } from 'mobx-react'; import styles from './errorScreen.module.scss'; import { getServerConfig } from 'config/config'; import { buildCBioPortalPageUrl } from 'shared/api/urls'; import { computed, makeObservable } from 'mobx'; import autobind from 'autobind-decorator'; var Clipboard = require('clipboard'); interface IErrorScreenProps { errorLog?: string; title?: string; body?: string | JSX.Element; errorMessages?: string[]; } @observer export default class ErrorScreen extends React.Component< IErrorScreenProps, {} > { constructor(props: IErrorScreenProps) { super(props); makeObservable(this); } @autobind copyToClipRef(copyToClip: HTMLButtonElement | null) { if (copyToClip) { new Clipboard(copyToClip, { text: function() { return JSON.stringify(this.errorLog); }.bind(this), container: copyToClip, }); } } @computed get errorLog() { let errorLog: any; try { errorLog = this.props.errorLog ? JSON.parse(this.props.errorLog) : undefined; // add the current url to error log if (errorLog) errorLog.url = window.location.href; } catch (ex) { errorLog = this.props.errorLog; } return errorLog; } public render() { const location = getBrowserWindow().location.href; const subject = 'cBioPortal user reported error'; return (
cBioPortal Logo {this.props.title &&

{this.props.title}

} {this.props.errorMessages && (
)} {this.props.body &&
{this.props.body}
} {this.errorLog && getServerConfig().skin_email_contact && (

Please contact us at{' '} {getServerConfig().skin_email_contact} .

Copy-paste the error log below and provide a click-by-click description of how you arrived at the error.

)} {this.errorLog && (
)}
); } }