<commit_before>import * as React from 'react';
import * as styles_any from './styles/styles.module.scss';
import { observer } from 'mobx-react';
import QueryContainer from './QueryContainer';
import { QueryStore } from './QueryStore';
import { observable, action } from 'mobx';
import { MSKTab, MSKTabs } from '../MSKTabs/MSKTabs';
import QuickSearch from './quickSearch/QuickSearch';
import { getBrowserWindow } from 'cbioportal-frontend-commons';
import autobind from 'autobind-decorator';
import { trackEvent } from 'shared/lib/tracking';
import { If } from 'react-if';
import AppConfig from 'appConfig';
import { ModifyQueryParams } from 'pages/resultsView/ResultsViewPageStore';

const styles = styles_any as {
    QueryAndDownloadTabs: string;
};

const DOWNLOAD = 'download';
const ADVANCED = 'advanced';
const QUICK_SEARCH_TAB_ID = 'quickSearch';
const QUICK_SEARCH_LS_KEY = 'defaultHomePageTab';

interface IQueryAndDownloadTabsProps {
    onSubmit?: () => void;
    showQuickSearchTab: boolean;
    showDownloadTab: boolean;
    getQueryStore: () => QueryStore;
    showAlerts?: boolean;
    forkedMode?: boolean;
    modifyQueryParams?: ModifyQueryParams | undefined;
}

@observer
export default class QueryAndDownloadTabs extends React.Component<
    IQueryAndDownloadTabsProps,
    {}
> {
    constructor(props: IQueryAndDownloadTabsProps) {
        super(props);

        if (
            props.showQuickSearchTab &&
            getBrowserWindow().localStorage.getItem(QUICK_SEARCH_LS_KEY) ===
                QUICK_SEARCH_TAB_ID
        ) {
            this.activeTabId = getBrowserWindow().localStorage.getItem(
                QUICK_SEARCH_LS_KEY
            );
        }

        // the query store models a single use of the query component and therefor a new one should
        // be made when the component is instantiated and it should be destroyed when the component unmounts
        // we use a callback because we want to create the query store at the moment the query form is instantiated/shown
        // because it needs the state of route at that moment (so that on the results page it reflects the current query)
        this.store = props.getQueryStore();
    }

    static defaultProps = {
        forkedMode: true,
    };

    @observable.ref store: QueryStore;

    @observable activeTabId: string;

    public get quickSearchDefaulted() {
        return (
            getBrowserWindow().localStorage.getItem(QUICK_SEARCH_LS_KEY) ===
            QUICK_SEARCH_TAB_ID
        );
    }

    @autobind
    setDefaultTab(tabId: string | undefined) {
        // right now we only care if quick search or NOT
        if (this.props.showQuickSearchTab) {
            getBrowserWindow().localStorage.defaultHomePageTab =
                tabId === QUICK_SEARCH_TAB_ID ? QUICK_SEARCH_TAB_ID : undefined;
        }
    }

    trackQuickSearch() {
        // track how many users are using this feature
        trackEvent({ category: 'quickSearch', action: 'quickSearchLoad' });
    }

    @autobind
    @action
    onSelectTab(tabId: string) {
        this.store.forDownloadTab = tabId === DOWNLOAD;
        this.store.selectableSelectedStudyIds = [];
        this.activeTabId = tabId;
    }

    render() {<commit_msg>do not clear selected study list when click query tab<commit_after>import * as React from 'react';
import * as styles_any from './styles/styles.module.scss';
import { observer } from 'mobx-react';
import QueryContainer from './QueryContainer';
import { QueryStore } from './QueryStore';
import { observable, action } from 'mobx';
import { MSKTab, MSKTabs } from '../MSKTabs/MSKTabs';
import QuickSearch from './quickSearch/QuickSearch';
import { getBrowserWindow } from 'cbioportal-frontend-commons';
import autobind from 'autobind-decorator';
import { trackEvent } from 'shared/lib/tracking';
import { If } from 'react-if';
import AppConfig from 'appConfig';
import { ModifyQueryParams } from 'pages/resultsView/ResultsViewPageStore';

const styles = styles_any as {
    QueryAndDownloadTabs: string;
};

const DOWNLOAD = 'download';
const ADVANCED = 'advanced';
const QUICK_SEARCH_TAB_ID = 'quickSearch';
const QUICK_SEARCH_LS_KEY = 'defaultHomePageTab';

interface IQueryAndDownloadTabsProps {
    onSubmit?: () => void;
    showQuickSearchTab: boolean;
    showDownloadTab: boolean;
    getQueryStore: () => QueryStore;
    showAlerts?: boolean;
    forkedMode?: boolean;
    modifyQueryParams?: ModifyQueryParams | undefined;
}

@observer
export default class QueryAndDownloadTabs extends React.Component<
    IQueryAndDownloadTabsProps,
    {}
> {
    constructor(props: IQueryAndDownloadTabsProps) {
        super(props);

        if (
            props.showQuickSearchTab &&
            getBrowserWindow().localStorage.getItem(QUICK_SEARCH_LS_KEY) ===
                QUICK_SEARCH_TAB_ID
        ) {
            this.activeTabId = getBrowserWindow().localStorage.getItem(
                QUICK_SEARCH_LS_KEY
            );
        }

        // the query store models a single use of the query component and therefor a new one should
        // be made when the component is instantiated and it should be destroyed when the component unmounts
        // we use a callback because we want to create the query store at the moment the query form is instantiated/shown
        // because it needs the state of route at that moment (so that on the results page it reflects the current query)
        this.store = props.getQueryStore();
    }

    static defaultProps = {
        forkedMode: true,
    };

    @observable.ref store: QueryStore;

    @observable activeTabId: string;

    public get quickSearchDefaulted() {
        return (
            getBrowserWindow().localStorage.getItem(QUICK_SEARCH_LS_KEY) ===
            QUICK_SEARCH_TAB_ID
        );
    }

    @autobind
    setDefaultTab(tabId: string | undefined) {
        // right now we only care if quick search or NOT
        if (this.props.showQuickSearchTab) {
            getBrowserWindow().localStorage.defaultHomePageTab =
                tabId === QUICK_SEARCH_TAB_ID ? QUICK_SEARCH_TAB_ID : undefined;
        }
    }

    trackQuickSearch() {
        // track how many users are using this feature
        trackEvent({ category: 'quickSearch', action: 'quickSearchLoad' });
    }

    @autobind
    @action
    onSelectTab(tabId: string) {
        this.store.forDownloadTab = tabId === DOWNLOAD;
        this.activeTabId = tabId;
    }

    render() {
{'fraction_non_alphanumeric': 0.09119010819165378, 'fraction_numerical': 0.0, 'mean_word_length': 3.016759776536313, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7482502', 'n_tokens_mistral': 1872, 'n_tokens_neox': 1802, 'n_words': 510}