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 ? (