From ff32ffae0ea770f5a90a1cb8314d2a85f16f6ff4 Mon Sep 17 00:00:00 2001 From: Artem Tarasov Date: Fri, 16 Apr 2021 11:24:33 +0300 Subject: [PATCH] Web: Files: Tiles: refactoring --- .../pages/Home/Section/Body/FilesContent.js | 52 ++++++++----------- .../Body/FilesTile/sub-components/Tile.js | 50 +++++++++--------- 2 files changed, 46 insertions(+), 56 deletions(-) diff --git a/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesContent.js b/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesContent.js index 969858b2cf..3c11d9f8dd 100644 --- a/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesContent.js +++ b/products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesContent.js @@ -444,6 +444,24 @@ class FilesContent extends React.Component { .catch((err) => toastr.error(err)); }; + renderFileExst = () => { + const { item } = this.props; + const { fileExst } = item; + return ( + + {fileExst} + + ); + }; + render() { const { itemTitle, showConvertDialog, newItems } = this.state; @@ -463,10 +481,6 @@ class FilesContent extends React.Component { id, fileExst, access, - locked, - fileStatus, - title, - versionGroup, createdBy, updated, providerKey, @@ -497,6 +511,8 @@ class FilesContent extends React.Component { ? { noHover: true } : { onClick: this.onFilesClick }; + const fileExstElement = this.renderFileExst(); + return isEdit ? ( {titleWithoutExt} - {fileExst && viewAs === "tile" ? ( - - {fileExst} - - ) : null} + {fileExst && viewAs === "tile" ? fileExstElement : null}
- {fileExst && viewAs !== "tile" ? ( - - {fileExst} - - ) : null} + {fileExst && viewAs !== "tile" ? fileExstElement : null}
; const FlexBoxStyles = css` display: flex; flex-direction: row; @@ -39,19 +41,19 @@ const StyledFileTileTop = styled.div` padding: 13px; height: 157px; position: relative; - user-select: none; .thumbnailImage { - position: absolute; - bottom: 0; - left: 0; - right: 0; - display: block; - margin: auto; - z-index: 0; + & > .injected-svg { + position: absolute; + left: 0; + right: 0; + bottom: 0; + margin: auto; + z-index: 0; + } } - .temporary-icon { + .temporary-icon > .injected-svg { margin-bottom: 16px; } `; @@ -127,6 +129,16 @@ class Tile extends React.Component { this.tile = React.createRef(); } + getIconFile() { + const { item, temporaryIcon } = this.props; + + const icon = item.thumbnail ? item.thumbnail : temporaryIcon; + let className = "thumbnailImage"; + if (!item.thumbnail) className += " temporary-icon"; + + return ; + } + render() { //console.log("Row render"); const { @@ -140,7 +152,6 @@ class Tile extends React.Component { onSelect, isFolder, rowContextClick, - temporaryIcon, } = this.props; const renderCheckbox = Object.prototype.hasOwnProperty.call( @@ -174,6 +185,8 @@ class Tile extends React.Component { this.cm.current.show(e); }; + const icon = this.getIconFile(); + return ( {isFolder ? ( @@ -207,19 +220,6 @@ class Tile extends React.Component { ) : ( <> - {item.thumbnail ? ( - thumbnail - ) : ( - thumbnail - )} {renderCheckbox && ( )} - { - // - } + {icon} {element}