import * as React from 'react'; import classNames from 'classnames'; import IReactComponentProps from '../../../common/structures/IReactComponentProps'; import ProgressBar from '../ProgressBar/ProgressBar'; import { TextButton } from '../../buttons/TextButton/TextButton'; import { FunctionGeneric } from '../../../common/structures/Generics'; import styles from './Downloader.scss'; import { Text } from '../../text/Text/Text'; import TimeAgo from 'react-timeago'; const { ipcRenderer } = require('electron'); export interface DownloaderItemProps extends IReactComponentProps { cancelText?: string; downloaded?: number; itemSize?: number; label?: string; onCancel?: FunctionGeneric; onCancelIPCEvent?: string; progress?: number; progressText?: string | number | boolean; truncateProgressText?: boolean; queueIndex?: number; queueLength?: number; showCancel?: boolean; showEllipsis?: boolean; stripes?: boolean; timeStamp?: number; timeStampText?: string; } const DownloaderItem = (props: DownloaderItemProps) => { const { cancelText = 'Cancel download', showEllipsis = true, downloaded, itemSize, label, onCancel, onCancelIPCEvent, progress, progressText, queueIndex, queueLength, showCancel, stripes, truncateProgressText, timeStamp, timeStampText, className, style, id, } = props; const cancelOnClick = (...args: any[]) => { if (onCancelIPCEvent) { ipcRenderer.send(onCancelIPCEvent); } if (onCancel) { return onCancel(...args); } }; return (
  • {(label || showEllipsis || (queueLength && queueIndex)) && {`${label || ''}${queueLength && queueLength > 1 ? ` (${(queueIndex || 0) + 1} of ${queueLength})` : ''}${showEllipsis ? '…' : ''}`} } {(timeStamp) && ( {timeStampText && `${timeStampText} - `} )}
    {(progressText || typeof itemSize === 'number') && ( {progressText || `${downloaded || 0}/${itemSize} MB`} )} {showCancel && ( {cancelText} )}
  • ); }; export default DownloaderItem; export interface DownloaderOverlayProps extends IReactComponentProps { downloaderItems: Array; } export const DownloaderOverlay = (props: DownloaderOverlayProps) => { const { downloaderItems, ...restProps } = props; return ( // Include global DownloaderOverlay classname for Playwright tests
    ); };