import * as React from 'react'; import CancerStudySelector from './CancerStudySelector'; import { FlexCol, FlexRow } from '../flexbox/FlexBox'; import styles from './styles/styles.module.scss'; import MolecularProfileSelector from './MolecularProfileSelector'; import { observer } from 'mobx-react'; import DataTypePrioritySelector from './DataTypePrioritySelector'; import GenesetsSelector from './GenesetsSelector'; import GeneSetSelector from './GeneSetSelector'; import LabeledCheckbox from '../labeledCheckbox/LabeledCheckbox'; import { QueryStore } from './QueryStore'; import { providesStoreContext } from '../../lib/ContextUtils'; import CaseSetSelector from './CaseSetSelector'; import UnknownStudiesWarning from '../unknownStudies/UnknownStudiesWarning'; import classNames from 'classnames'; import LoadingIndicator from '../loadingIndicator/LoadingIndicator'; import { computed, observable, makeObservable } from 'mobx'; import { Else, If, Then } from 'react-if'; import autobind from 'autobind-decorator'; import SectionHeader from 'shared/components/sectionHeader/SectionHeader'; import { Fade } from 'react-reveal'; import { DefaultTooltip } from 'cbioportal-frontend-commons'; import { StudySelectorStats } from 'shared/components/query/StudySelectorStats'; import $ from 'jquery'; import { serializeEvent } from 'shared/lib/tracking'; import { ModifyQueryParams } from 'pages/resultsView/ResultsViewPageStore'; interface QueryContainerProps { store: QueryStore; onSubmit?: () => void; forkedMode?: boolean; modifyQueryParams?: ModifyQueryParams | undefined; showAlerts?: boolean; } @providesStoreContext(QueryStore) @observer export default class QueryContainer extends React.Component< QueryContainerProps, {} > { get store() { return this.props.store; } // indicates we have loaded the study data necessary to show default selected studies (e.g. modify query scenario), studiesHaveChangedSinceInitialization indicates all data is ready and we don't need to consider other conditions anymore. @computed get studiesDataReady(): boolean { return ( this.store.studiesHaveChangedSinceInitialization || (this.store.selectableStudiesSet.isComplete && this.store.initiallySelected.profileIds && this.store.cancerTypes.isComplete && this.store.cancerStudies.isComplete && this.store.profiledSamplesCount.isComplete) ); } @observable _showQueryControls = false; @computed get showQueryControls() { return this.props.forkedMode === false || this._showQueryControls; } constructor(props: QueryContainerProps) { super(props); makeObservable(this); this.handleSubmit = this.handleSubmit.bind(this); } @computed get selectedStudySummary() { const LIMIT = 4; let overflow: JSX.Element | null = null; if (this.store.selectableSelectedStudies.length > LIMIT) { const overlay = () => this.store.selectableSelectedStudies .slice(LIMIT) .map(study =>
{study.name}
); overflow = ( and{' '} {this.store.selectableSelectedStudies.length - LIMIT}{' '} more ); } return ( {this.store.selectableSelectedStudies .slice(0, LIMIT) .reduce((acc: (string | JSX.Element)[], study, i, arr) => { acc.push( {study.name} ); return acc; }, [])} {overflow} {overflow &&  }( {this.store.profiledSamplesCount.result.all}{' '} {this.store.profiledSamplesCount.result.all === 1 ? 'sample' : 'total samples'} ) ); } @computed get getWrappedCancerStudySelector() { const control = ( Looking for AACR Project GENIE, the largest public clinicogenomic cancer dataset?  It's available here. {' '} ) : ( undefined ) } /> ); //NOTE: we have to wrap with div in order to deal with margin applied by css selector //react-reveal does not allow us to add inline-css to it's wrapper return this.props.forkedMode ? (
{control}
) : ( control ); } handleSubmit() { this.store.submit(); if (this.props.onSubmit) { this.props.onSubmit(); } } @autobind toggleQueryControls() { // scroll to top $(document).scrollTop(0); this._showQueryControls = !this._showQueryControls; } @computed get studyLimitedReached() { return this.store.selectableSelectedStudyIds.length > 50; } @computed get exploreCohortsButtonDisabled() { return this.studyLimitedReached || !this.store.hasSelectedStudies; } @computed get exploreCohortsButtonTooltipMessage() { if (this.store.selectableSelectedStudyIds.length === 0) { return 'Please select at least one study above'; } else if (this.studyLimitedReached) { return 'Too many studies selected for study summary (limit: 50)'; } else { return 'Open summary of selected studies'; } } @computed get queryByGeneTooltipMessage() { if (this.store.selectableSelectedStudies.length === 0) { return 'Please select at least one study above'; } else { return 'Continue to query configuration'; } } render(): JSX.Element { return ( {this.props.showAlerts && this.store.genes.isComplete && this.store.genes.result.suggestions.length > 0 && (
Your query has invalid or out-dated gene symbols. Please correct below.
)} {this.store.unknownStudyIds.isComplete && ( )} {this.store.forDownloadTab && (
The Download interface has been removed. Enhanced download functionality is now available through the Query interface. Run a query with your gene(s) of interest and use the Download tab to download all available data types.
)} {!this.store.forDownloadTab && ( Selected Studies:{' '}
{this.selectedStudySummary}
{this.getWrappedCancerStudySelector} <> {this.store.physicalStudyIdsInSelection .length > 1 ? ( ) : ( )} {this.store.selectableSelectedStudyIds .length > 0 && ( )} {!!this.store.isGenesetProfileSelected && ( )} {!!this.store.forDownloadTab && ( Clicking submit will generate a tab-delimited file containing your requested data. )} {!!this.store.forDownloadTab && ( (this.store.transposeDataMatrix = event.currentTarget.checked) } > Transpose data matrix )}
0 } overlay={this.queryByGeneTooltipMessage} > this.store.hasSelectedStudies && this.toggleQueryControls() } data-event={serializeEvent({ action: 'clickQueryByGeneButton', label: '', category: 'homePage', })} className={classNames( 'btn btn-primary btn-lg', { disabled: !this.store .hasSelectedStudies, } )} > Query By Gene OR !this .exploreCohortsButtonDisabled && this.store.openSummary() } data-event={serializeEvent({ action: 'clickExploreStudiesButton', label: '', category: 'homePage', })} className={classNames( 'btn btn-primary btn-lg', { disabled: this .exploreCohortsButtonDisabled, } )} > {' '} Explore Selected Studies
)}
); } }