From 8ba5e9435bb29b442e92ea0dde115f6a6c707f3d Mon Sep 17 00:00:00 2001 From: llj Date: Wed, 5 Feb 2020 19:42:28 +0800 Subject: [PATCH] [shared dir view] added support for mobile (#4425) --- frontend/src/shared-dir-view.js | 126 +++++++++++++++++++++++++++----- 1 file changed, 108 insertions(+), 18 deletions(-) diff --git a/frontend/src/shared-dir-view.js b/frontend/src/shared-dir-view.js index c06a090b4b..36db3926a9 100644 --- a/frontend/src/shared-dir-view.js +++ b/frontend/src/shared-dir-view.js @@ -1,6 +1,6 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { Button } from 'reactstrap'; +import { Button, Dropdown, DropdownToggle, DropdownItem } from 'reactstrap'; import moment from 'moment'; import Account from './components/common/account'; import { gettext, siteRoot, mediaUrl, logoPath, logoWidth, logoHeight, siteTitle, thumbnailSizeForOriginal } from './utils/constants'; @@ -193,6 +193,7 @@ class SharedDirView extends React.Component { } render() { + const isDesktop = Utils.isDesktop(); const modeBaseClass = 'btn btn-secondary btn-icon sf-view-mode-btn'; return ( @@ -210,16 +211,19 @@ class SharedDirView extends React.Component {

{gettext('Current path: ')}{this.renderPath()}

+ {isDesktop &&
+ } {showDownloadIcon && }
; @@ -291,6 +295,35 @@ class Content extends React.Component { return

{errorMsg}

; } + const tbody = ( + + {items.map((item, index) => { + return ; + })} + + ); + + if (!isDesktop) { + return ( + + + + + + + + + {tbody} +
+ ); + } + const sortIcon = ; return mode == 'list' ? ( @@ -303,16 +336,7 @@ class Content extends React.Component { - - {items.map((item, index) => { - return ; - })} - + {tbody}
) : (
    @@ -334,10 +358,15 @@ class Item extends React.Component { constructor(props) { super(props); this.state = { - isIconShown: false + isIconShown: false, + isOpMenuOpen: false }; } + toggleOpMenu = () => { + this.setState({isOpMenuOpen: !this.state.isOpMenuOpen}); + } + handleMouseOver = () => { this.setState({isIconShown: true}); } @@ -362,11 +391,11 @@ class Item extends React.Component { } render() { - const item = this.props.item; + const { item, isDesktop } = this.props; const { isIconShown } = this.state; if (item.is_dir) { - return ( + return isDesktop ? ( @@ -381,11 +410,39 @@ class Item extends React.Component { } + ) : ( + + + + {item.folder_name} +
    + {moment(item.last_modified).fromNow()} + + + {showDownloadIcon && + + +
    +
    +
    + {gettext('Download')} +
    +
    +
    + } + + ); } else { const fileURL = `${siteRoot}d/${token}/files/?p=${encodeURIComponent(item.file_path)}`; const thumbnailURL = item.encoded_thumbnail_src ? `${siteRoot}${item.encoded_thumbnail_src}` : ''; - return ( + return isDesktop ? ( {thumbnailURL ? @@ -400,8 +457,41 @@ class Item extends React.Component { {moment(item.last_modified).fromNow()} {showDownloadIcon && - - + + } + + + ) : ( + + + {thumbnailURL ? + : + + } + + + {item.file_name} +
    + {Utils.bytesToSize(item.size)} + {moment(item.last_modified).fromNow()} + + + {showDownloadIcon && + + +
    +
    +
    + {gettext('Download')} +
    +
    +
    }