import * as React from 'react'; import { CancerStudy } from 'cbioportal-ts-api-client'; import { computed, observable, makeObservable } from 'mobx'; import { observer } from 'mobx-react'; import classnames from 'classnames'; import _ from 'lodash'; import styles from '../styles.module.scss'; import { StudySummaryRecord } from '../../virtualStudy/VirtualStudy'; import LoadingIndicator from '../../../../shared/components/loadingIndicator/LoadingIndicator'; import { getStudySummaryUrl } from '../../../../shared/api/urls'; import { DefaultTooltip, getNCBIlink } from 'cbioportal-frontend-commons'; import MobxPromise from 'mobxpromise'; import { StudyDataDownloadLink } from '../../../../shared/components/StudyDataDownloadLink/StudyDataDownloadLink'; import { serializeEvent } from '../../../../shared/lib/tracking'; import { mixedReferenceGenomeWarning } from 'shared/lib/referenceGenomeUtils'; import { AppContext } from 'cbioportal-frontend-commons'; interface IStudySummaryProps { studies: CancerStudy[]; hasRawDataForDownload: boolean; originStudies: MobxPromise; showOriginStudiesInSummaryDescription: boolean; isMixedReferenceGenome: boolean | undefined; } @observer export default class StudySummary extends React.Component< IStudySummaryProps, {} > { constructor(props: any) { super(props); makeObservable(this); } @observable private showMoreDescription = false; @computed get name() { return this.props.studies.length === 1 ? this.props.studies[0].name : 'Combined Study'; } @computed get descriptionFirstLine() { if (this.props.studies.length === 1) { let elems = [ , ]; if (this.props.studies[0].pmid) { elems.push( PubMed ); } return {elems}; } else { return ( {`This combined study contains samples from ${this.props.studies.length} studies`} ); } } @computed get hasMoreDescription() { return ( this.props.showOriginStudiesInSummaryDescription || this.props.studies.length > 1 || this.props.studies[0].description.split(/\n/g).length > 1 ); } @computed get descriptionRemainingLines() { if (this.props.studies.length === 1) { const lines = this.props.studies[0].description.split(/\n/g); if (lines.length > 1) { //slice fist line as its already shown return [ , ]; } } else { return _.map(this.props.studies, study => { return (
  • {study.name}
  • ); }); } return []; } @computed get showDownload() { return ( this.props.hasRawDataForDownload && this.context.showDownloadControls === true ); } render() { return (

    {this.name} {this.props.isMixedReferenceGenome && mixedReferenceGenomeWarning()} {this.showDownload && ( Download all clinical and genomic data of this study } > s.studyId) .join(','), })} style={{ marginLeft: '10px', fontSize: '14px' }} > )}

    {this.descriptionFirstLine} {this.hasMoreDescription && ( (this.showMoreDescription = !this .showMoreDescription) } style={{ marginLeft: '5px', cursor: 'pointer' }} /> )}
    {this.showMoreDescription && (
      {this.descriptionRemainingLines}
    {this.props .showOriginStudiesInSummaryDescription && (
    {this.props.originStudies.isComplete && this.props.originStudies.result! .length > 0 && ( This virtual study was derived from: {this.props.originStudies.result!.map( study => ( ) )} )}
    )}
    )}
    ); } } StudySummary.contextType = AppContext;