From c7eff6883f7969701d8ca7827b0f396d3bed0e5b Mon Sep 17 00:00:00 2001 From: zxawry Date: Sun, 12 May 2019 15:46:14 +0100 Subject: [PATCH 1/3] show warning when opening external files and links --- src/ui/component/externalLink/view.jsx | 2 +- src/ui/component/fileDownloadLink/index.js | 4 +- src/ui/component/fileDownloadLink/view.jsx | 24 ++++++---- src/ui/constants/modal_types.js | 2 +- src/ui/modal/modalOpenExternalLink/index.js | 12 ----- src/ui/modal/modalOpenExternalLink/view.jsx | 52 --------------------- src/ui/modal/modalRouter/view.jsx | 6 +-- 7 files changed, 21 insertions(+), 81 deletions(-) delete mode 100644 src/ui/modal/modalOpenExternalLink/index.js delete mode 100644 src/ui/modal/modalOpenExternalLink/view.jsx diff --git a/src/ui/component/externalLink/view.jsx b/src/ui/component/externalLink/view.jsx index 95dd429b0..ccab6ad27 100644 --- a/src/ui/component/externalLink/view.jsx +++ b/src/ui/component/externalLink/view.jsx @@ -37,7 +37,7 @@ class ExternalLink extends React.PureComponent { title={title || href} label={children} className="button--external-link" - onClick={() => openModal(MODALS.CONFIRM_EXTERNAL_LINK, { uri: href })} + onClick={() => openModal(MODALS.CONFIRM_EXTERNAL_RESOURCE, { uri: href })} /> ); } diff --git a/src/ui/component/fileDownloadLink/index.js b/src/ui/component/fileDownloadLink/index.js index 50519c69b..b511885bc 100644 --- a/src/ui/component/fileDownloadLink/index.js +++ b/src/ui/component/fileDownloadLink/index.js @@ -6,7 +6,7 @@ import { makeSelectClaimForUri, } from 'lbry-redux'; import { makeSelectCostInfoForUri } from 'lbryinc'; -import { doOpenFileInShell } from 'redux/actions/file'; +import { doOpenModal } from 'redux/actions/app'; import { doPurchaseUri, doStartDownload, doSetPlayingUri } from 'redux/actions/content'; import FileDownloadLink from './view'; @@ -20,7 +20,7 @@ const select = (state, props) => ({ }); const perform = dispatch => ({ - openInShell: path => dispatch(doOpenFileInShell(path)), + openModal: (modal, props) => dispatch(doOpenModal(modal, props)), purchaseUri: uri => dispatch(doPurchaseUri(uri)), restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint)), pause: () => dispatch(doSetPlayingUri(null)), diff --git a/src/ui/component/fileDownloadLink/view.jsx b/src/ui/component/fileDownloadLink/view.jsx index 9ac82ba80..0d3178390 100644 --- a/src/ui/component/fileDownloadLink/view.jsx +++ b/src/ui/component/fileDownloadLink/view.jsx @@ -1,5 +1,6 @@ // @flow import * as ICONS from 'constants/icons'; +import * as MODALS from 'constants/modal_types'; import React from 'react'; import Button from 'component/button'; import ToolTip from 'component/common/tooltip'; @@ -20,7 +21,7 @@ type Props = { loading: boolean, costInfo: ?{}, restartDownload: (string, number) => void, - openInShell: string => void, + openModal: (id: string, { path: string }) => void, purchaseUri: string => void, pause: () => void, }; @@ -43,14 +44,7 @@ class FileDownloadLink extends React.PureComponent { uri: ?string; render() { - const { fileInfo, downloading, uri, openInShell, purchaseUri, costInfo, loading, pause, claim } = this.props; - - const openFile = () => { - if (fileInfo) { - openInShell(fileInfo.download_path); - pause(); - } - }; + const { fileInfo, downloading, uri, openModal, purchaseUri, costInfo, loading, pause, claim } = this.props; if (loading || downloading) { const progress = fileInfo && fileInfo.written_bytes ? (fileInfo.written_bytes / fileInfo.total_bytes) * 100 : 0; @@ -83,7 +77,17 @@ class FileDownloadLink extends React.PureComponent { } else if (fileInfo && fileInfo.download_path) { return ( -