import React, { Component } from "react"; import PropTypes from "prop-types"; import { connect } from "react-redux"; import { navitateTo, changeContextMenu, navitateUp, setSelectedTarget, openRemoveDialog, changeSortMethod, refreshFileList } from "../../actions/index"; import ObjectIcon from "./ObjectIcon"; import ContextMenu from "./ContextMenu"; import EmptyIcon from "@material-ui/icons/Unarchive"; import SadIcon from "@material-ui/icons/SentimentVeryDissatisfied"; import classNames from "classnames"; import ImgPreivew from "./ImgPreview"; import UpIcon from "@material-ui/icons/ArrowUpward"; import pathHelper from "../../untils/page"; import { withRouter } from "react-router-dom"; import { Table, TableBody, TableCell, TableHead, TableRow, withStyles, Typography, Grid, CircularProgress, Paper, Button } from "@material-ui/core"; import { GlobalHotKeys } from "react-hotkeys"; import TableSortLabel from "@material-ui/core/TableSortLabel"; const styles = theme => ({ paper: { padding: theme.spacing(2), textAlign: "center", color: theme.palette.text.secondary, margin: "10px" }, root: { flexGrow: 1, padding: "10px", overflowY: "auto", height: "calc(100vh - 113px)", [theme.breakpoints.up("sm")]: { overflowY: "auto", height: "calc(100vh - 113px)" }, [theme.breakpoints.down("sm")]: { height: "100%" } }, rootTable: { padding: "0px", backgroundColor: theme.palette.background.paper.white, [theme.breakpoints.up("sm")]: { overflowY: "auto", height: "calc(100vh - 113px)" }, [theme.breakpoints.down("sm")]: { height: "100%" } }, typeHeader: { margin: "10px 25px", color: "#6b6b6b", fontWeight: "500" }, loading: { justifyContent: "center", display: "flex", marginTop: "40px" }, errorBox: { padding: theme.spacing(4) }, errorMsg: { marginTop: "10px" }, emptyContainer: { bottom: "0", height: "300px", margin: "50px auto", width: "300px", color: theme.palette.explorer.emptyIcon, textAlign: "center", paddingTop: "20px" }, emptyIcon: { fontSize: "160px" }, emptyInfoBig: { fontSize: "25px", color: theme.palette.text.disabled }, emptyInfoSmall: { color: theme.palette.text.hint }, hideAuto: { [theme.breakpoints.down("sm")]: { display: "none" } }, flexFix: { minWidth: 0 }, upButton: { marginLeft: "20px", marginTop: "10px", marginBottom: "10px" }, clickAway: { height: "100%", width: "100%" }, rootShare: { height: "100%", minHeight: 500 }, visuallyHidden: { border: 0, clip: "rect(0 0 0 0)", height: 1, margin: -1, overflow: "hidden", padding: 0, position: "absolute", top: 20, width: 1 } }); const mapStateToProps = state => { return { path: state.navigator.path, drawerDesktopOpen: state.viewUpdate.open, viewMethod: state.viewUpdate.explorerViewMethod, sortMethod: state.viewUpdate.sortMethod, fileList: state.explorer.fileList, dirList: state.explorer.dirList, loading: state.viewUpdate.navigatorLoading, navigatorError: state.viewUpdate.navigatorError, navigatorErrorMsg: state.viewUpdate.navigatorErrorMsg, keywords: state.explorer.keywords, selected: state.explorer.selected }; }; const mapDispatchToProps = dispatch => { return { navigateToPath: path => { dispatch(navitateTo(path)); }, changeContextMenu: (type, open) => { dispatch(changeContextMenu(type, open)); }, navitateUp: () => { dispatch(navitateUp()); }, setSelectedTarget: targets => { dispatch(setSelectedTarget(targets)); }, openRemoveDialog: () => { dispatch(openRemoveDialog()); }, changeSort: method => { dispatch(changeSortMethod(method)); } }; }; class ExplorerCompoment extends Component { constructor() { super(); this.keyMap = { DELETE_FILE: "del", SELECT_ALL: "ctrl+a" }; this.handlers = { DELETE_FILE: () => { if (this.props.selected.length > 0 && !this.props.share) { this.props.openRemoveDialog(); } }, SELECT_ALL: e => { e.preventDefault(); if ( this.props.selected.length >= this.props.dirList.length + this.props.fileList.length ) { this.props.setSelectedTarget([]); } else { this.props.setSelectedTarget([ ...this.props.dirList, ...this.props.fileList ]); } } }; } contextMenu = e => { e.preventDefault(); if ( this.props.keywords === null && !pathHelper.isSharePage(this.props.location.pathname) ) { if (!this.props.loading) { this.props.changeContextMenu("empty", true); } } }; componentDidUpdate(prevProps, prevState, snapshot) { this.away = 0; } ClickAway = e => { let element = e.target; if (element.dataset.clickaway) { this.props.setSelectedTarget([]); } }; render() { const { classes } = this.props; const isHomePage = pathHelper.isHomePage(this.props.location.pathname); return (