From 7a10e0eda93f1d89966249c524d290f1eb784b8c Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Mon, 21 May 2018 16:30:00 -0400 Subject: [PATCH] move file actions below video player --- src/renderer/component/common/icon.jsx | 6 +- src/renderer/component/fileActions/view.jsx | 10 ++- .../component/fileDownloadLink/view.jsx | 71 ++++++++++--------- .../component/subscribeButton/view.jsx | 2 +- .../component/video/internal/play-button.jsx | 2 +- src/renderer/page/file/view.jsx | 15 ++-- src/renderer/scss/component/_card.scss | 5 +- .../scss/component/_file-download.scss | 25 +------ 8 files changed, 63 insertions(+), 73 deletions(-) diff --git a/src/renderer/component/common/icon.jsx b/src/renderer/component/common/icon.jsx index b0a05d879..7bfc3ae0c 100644 --- a/src/renderer/component/common/icon.jsx +++ b/src/renderer/component/common/icon.jsx @@ -1,10 +1,10 @@ // @flow import React from 'react'; -// import * as icons from 'constants/icons'; import * as FeatherIcons from 'react-feather'; import * as icons from 'constants/icons'; const RED_COLOR = '#e2495e'; +const PURPLE_COLOR = '#8165b0'; type Props = { icon: string, @@ -19,8 +19,10 @@ class IconComponent extends React.PureComponent { const Icon = FeatherIcons[icon]; let color; - if (icon === icons.HEART || icon === icons.FEATURED) { + if (icon === icons.TRASH || icon === icons.FEATURED) { color = RED_COLOR; + } else if (icon === icons.OPEN) { + color = PURPLE_COLOR; } let size = 14; diff --git a/src/renderer/component/fileActions/view.jsx b/src/renderer/component/fileActions/view.jsx index 94995d245..a485cc90e 100644 --- a/src/renderer/component/fileActions/view.jsx +++ b/src/renderer/component/fileActions/view.jsx @@ -1,7 +1,6 @@ // @flow import React from 'react'; import Button from 'component/button'; -import FileDownloadLink from 'component/fileDownloadLink'; import { MODALS } from 'lbry-redux'; import classnames from 'classnames'; import * as icons from 'constants/icons'; @@ -27,21 +26,20 @@ class FileActions extends React.PureComponent { return (
- {showDelete && (
diff --git a/src/renderer/component/fileDownloadLink/view.jsx b/src/renderer/component/fileDownloadLink/view.jsx index c2c413bd6..0658ae253 100644 --- a/src/renderer/component/fileDownloadLink/view.jsx +++ b/src/renderer/component/fileDownloadLink/view.jsx @@ -1,19 +1,39 @@ +// @flow import React from 'react'; import Button from 'component/button'; -import classnames from 'classnames'; import * as icons from 'constants/icons'; -class FileDownloadLink extends React.PureComponent { +type Props = { + uri: string, + downloading: boolean, + fileInfo: ?{ + written_bytes: number, + total_bytes: number, + outpoint: number, + download_path: string, + }, + loading: boolean, + costInfo: ?{}, + restartDownload: (string, number) => void, + checkAvailability: string => void, + openInShell: string => void, + purchaseUri: string => void, + doPause: () => void, +}; + +class FileDownloadLink extends React.PureComponent { componentWillMount() { this.checkAvailability(this.props.uri); } - componentWillReceiveProps(nextProps) { + componentWillReceiveProps(nextProps: Props) { this.checkAvailability(nextProps.uri); this.restartDownload(nextProps); } - restartDownload(props) { + uri: ?string; + + restartDownload = (props: Props) => { const { downloading, fileInfo, uri, restartDownload } = props; if ( @@ -25,11 +45,11 @@ class FileDownloadLink extends React.PureComponent { ) { restartDownload(uri, fileInfo.outpoint); } - } + }; - checkAvailability(uri) { - if (!this._uri || uri !== this._uri) { - this._uri = uri; + checkAvailability(uri: string) { + if (!this.uri || uri !== this.uri) { + this.uri = uri; this.props.checkAvailability(uri); } } @@ -47,8 +67,10 @@ class FileDownloadLink extends React.PureComponent { } = this.props; const openFile = () => { - openInShell(fileInfo.download_path); - doPause(); + if (fileInfo) { + openInShell(fileInfo.download_path); + doPause(); + } }; if (loading || downloading) { @@ -56,21 +78,11 @@ class FileDownloadLink extends React.PureComponent { fileInfo && fileInfo.written_bytes ? fileInfo.written_bytes / fileInfo.total_bytes * 100 : 0; - const label = fileInfo ? progress.toFixed(0) + __('% complete') : __('Connecting...'); + const label = fileInfo + ? __('Downloading: ') + progress.toFixed(0) + __('% complete') + : __('Connecting...'); - return ( -
-
- {label} -
- {label} -
- ); + return {label}; } else if (fileInfo === null && !downloading) { if (!costInfo) { return null; @@ -78,8 +90,8 @@ class FileDownloadLink extends React.PureComponent { return (