import * as React from 'react'; import { ICopyDownloadInputsProps } from './ICopyDownloadControls'; import classnames from 'classnames'; import styles from './copyDownloadControls.module.scss'; import { DefaultTooltip } from 'cbioportal-frontend-commons'; import VirtualStudy, { IVirtualStudyProps, } from 'pages/studyView/virtualStudy/VirtualStudy'; import { computed } from 'mobx'; import { AppContext } from 'cbioportal-frontend-commons'; export interface ICopyDownloadLinksProps extends ICopyDownloadInputsProps { copyLinkRef?: (el: HTMLAnchorElement | null) => void; showQuery?: boolean; showVirtualStudy?: boolean; queryButtonLabel?: string; virtualStudyButtonLabel?: string; handleQuery?: () => void; virtualStudyParams?: IVirtualStudyProps; } export class CopyDownloadQueryLinks extends React.Component< ICopyDownloadLinksProps, {} > { public static defaultProps = { className: '', copyButtonLabel: 'Copy', downloadButtonLabel: 'Download', queryButtonLabel: 'Query', virtualStudyButtonLabel: 'Virtual Study', showCopy: true, showDownload: true, showQuery: false, showVirtualStudy: false, }; @computed get showDownload() { return ( this.props.showDownload && this.context.showDownloadControls === true ); } @computed get showCopy() { return ( this.props.showCopy && this.context.showDownloadControls === true ); } public render() { return ( {this.showCopy && ( {this.props.copyLabel} )} {this.showCopy && this.showDownload && |} {this.showDownload && ( {this.props.downloadLabel} )} {this.showDownload && this.props.showQuery && |} {this.props.showQuery && ( {this.props.queryButtonLabel} )} {this.props.showQuery && this.props.showVirtualStudy && ( | )} {this.props.showVirtualStudy && ( ) } placement="bottom" > {this.props.virtualStudyButtonLabel} )} {this.props.showCopyMessage && ( Copied! )} ); } } CopyDownloadQueryLinks.contextType = AppContext;