import * as React from 'react'; import { ICopyDownloadInputsProps } from './ICopyDownloadControls'; import { AppContext } from 'cbioportal-frontend-commons'; import { computed } from 'mobx'; export interface ICopyDownloadLinksProps extends ICopyDownloadInputsProps { copyLinkRef?: (el: HTMLAnchorElement | null) => void; } export class CopyDownloadLinks extends React.Component< ICopyDownloadLinksProps, {} > { public static defaultProps = { className: '', copyButtonLabel: 'Copy', downloadButtonLabel: 'Download', showCopy: true, showDownload: true, }; @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.props.showCopyMessage && ( Copied! )} ); } } CopyDownloadLinks.contextType = AppContext;