<commit_before>import * as React from "react";
import {observer} from "mobx-react";
import {
    caseCountsInParens,
    ComparisonGroup,
    getSampleIdentifiers,
    getPatientIdentifiers
} from "./GroupComparisonUtils";
import MobxPromise from "mobxpromise";
import { ButtonGroup, Button } from "react-bootstrap";
import { MakeMobxView } from "shared/components/MobxView";
import LoadingIndicator from "shared/components/loadingIndicator/LoadingIndicator";
import ErrorMessage from "shared/components/ErrorMessage";
import _ from "lodash";
import GroupComparisonStore from "./GroupComparisonStore";
import classNames from "classnames";
import ListIndexedMap from "shared/lib/ListIndexedMap";
import { SampleIdentifier, PatientIdentifier } from "shared/api/generated/CBioPortalAPI";
import styles from './styles.module.scss';

export interface IGroupSelectorProps {
    store:GroupComparisonStore;
}

@observer
export default class GroupSelector extends React.Component<IGroupSelectorProps,{}> {
    readonly tabUI = MakeMobxView({
        await:()=>[
            this.props.store.filteredGroups,
            this.props.store.sampleSet
        ],
        render:()=>{
            if (this.props.store.filteredGroups.result!.length === 0) {
                return null;
            } else {
                return (
                    <div>
                        <strong>Active Groups: </strong>
                        <div className={styles.groupButtons}>
                            {this.props.store.filteredGroups.result!.map(group=>{
                                const active = this.props.store.isGroupActive(group);
                                const sampleIdentifiers = getSampleIdentifiers([group]);
                                const patientIdentifiers = getPatientIdentifiers(sampleIdentifiers, this.props.store.sampleSet.result!);
                                return (
                                    <button
                                        className={classNames('btn btn-xs', { "btn-primary":active, "btn-default":!active})}
                                        onClick={()=>this.props.store.toggleGroupSelected(group.uid)}
                                        disabled={!this.props.store.groupSelectionCanBeToggled(group)}
                                    >
                                        {
                                            active ? <i className={'fa fa-check'}></i> : null
                                        }
                                        &nbsp;
                                        {`${group.name} ${
                                            caseCountsInParens(sampleIdentifiers, patientIdentifiers, group.hasOverlappingSamples, group.hasOverlappingPatients)
                                        }`}
                                    </button>
                                );
                            })}
                        </div>
                    </div><commit_msg>group comparison page - show warning when nonexistent samples filtered from a group<commit_after>import * as React from "react";
import {observer} from "mobx-react";
import {
    caseCountsInParens,
    ComparisonGroup,
    getSampleIdentifiers,
    getPatientIdentifiers, getMissingSamplesMessage
} from "./GroupComparisonUtils";
import MobxPromise from "mobxpromise";
import { ButtonGroup, Button } from "react-bootstrap";
import { MakeMobxView } from "shared/components/MobxView";
import LoadingIndicator from "shared/components/loadingIndicator/LoadingIndicator";
import ErrorMessage from "shared/components/ErrorMessage";
import _ from "lodash";
import GroupComparisonStore from "./GroupComparisonStore";
import classNames from "classnames";
import ListIndexedMap from "shared/lib/ListIndexedMap";
import { SampleIdentifier, PatientIdentifier } from "shared/api/generated/CBioPortalAPI";
import styles from './styles.module.scss';
import ErrorIcon from "../../shared/components/ErrorIcon";

export interface IGroupSelectorProps {
    store:GroupComparisonStore;
}

@observer
export default class GroupSelector extends React.Component<IGroupSelectorProps,{}> {
    readonly tabUI = MakeMobxView({
        await:()=>[
            this.props.store.filteredGroups,
            this.props.store.sampleSet
        ],
        render:()=>{
            if (this.props.store.filteredGroups.result!.length === 0) {
                return null;
            } else {
                return (
                    <div>
                        <strong>Active Groups: </strong>
                        <div className={styles.groupButtons}>
                            {this.props.store.filteredGroups.result!.map(group=>{
                                const active = this.props.store.isGroupActive(group);
                                const sampleIdentifiers = getSampleIdentifiers([group]);
                                const patientIdentifiers = getPatientIdentifiers(sampleIdentifiers, this.props.store.sampleSet.result!);
                                return (
                                    <button
                                        className={classNames('btn btn-xs', { "btn-primary":active, "btn-default":!active})}
                                        onClick={()=>this.props.store.toggleGroupSelected(group.uid)}
                                        disabled={!this.props.store.groupSelectionCanBeToggled(group)}
                                    >
                                        {
                                            active ? <i className={'fa fa-check'}></i> : null
                                        }
                                        &nbsp;
                                        {`${group.name} ${
                                            caseCountsInParens(sampleIdentifiers, patientIdentifiers, group.hasOverlappingSamples, group.hasOverlappingPatients)
                                        }`}
                                        {group.nonExistentSamples.length > 0 && <ErrorIcon style={{marginLeft:7}} tooltip={getMissingSamplesMessage(group.nonExistentSamples)}/>}
                                    </button>
                                );
                            })}
                        </div>
                    </div>
{'fraction_non_alphanumeric': 0.09391387255680915, 'fraction_numerical': 0.0006356268870173208, 'mean_word_length': 1.544058205335489, 'pattern_counts': {'":': 4, '<': 26, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 31, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5440695', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1348, 'n_words': 270}