From bd3872a677b5368961b4f8c800e6016e98ae4ccb Mon Sep 17 00:00:00 2001 From: ShawnYuan Date: Wed, 30 Aug 2023 11:45:22 +0800 Subject: [PATCH] feat: replace sort action with compoent `Sort` --- .../FileManager/Navigator/SubActions.js | 66 +++---------------- 1 file changed, 10 insertions(+), 56 deletions(-) diff --git a/src/component/FileManager/Navigator/SubActions.js b/src/component/FileManager/Navigator/SubActions.js index 4d648be..5890e91 100644 --- a/src/component/FileManager/Navigator/SubActions.js +++ b/src/component/FileManager/Navigator/SubActions.js @@ -3,7 +3,6 @@ import { IconButton, makeStyles, Menu, MenuItem } from "@material-ui/core"; import ViewListIcon from "@material-ui/icons/ViewList"; import ViewSmallIcon from "@material-ui/icons/ViewComfy"; import ViewModuleIcon from "@material-ui/icons/ViewModule"; -import TextTotateVerticalIcon from "@material-ui/icons/TextRotateVertical"; import DownloadIcon from "@material-ui/icons/CloudDownload"; import Avatar from "@material-ui/core/Avatar"; import { useDispatch, useSelector } from "react-redux"; @@ -14,6 +13,7 @@ import { FormatPageBreak } from "mdi-material-ui"; import pathHelper from "../../../utils/page"; import { changePageSize } from "../../../redux/viewUpdate/action"; import { useTranslation } from "react-i18next"; +import Sort from "../Sort"; const useStyles = makeStyles((theme) => ({ sideButton: { @@ -22,17 +22,6 @@ const useStyles = makeStyles((theme) => ({ }, })); -const sortOptions = [ - "A-Z", - "Z-A", - "oldestUploaded", - "newestUploaded", - "oldestModified", - "newestModified", - "smallest", - "largest", -]; - const paginationOption = ["50", "100", "200", "500", "1000"]; export default function SubActions({ isSmall, inherit }) { @@ -63,29 +52,14 @@ export default function SubActions({ isSmall, inherit }) { const ChangePageSize = useCallback((e) => dispatch(changePageSize(e)), [ dispatch, ]); - const [anchorSort, setAnchorSort] = useState(null); const [anchorPagination, setAnchorPagination] = useState(null); - const [selectedIndex, setSelectedIndex] = useState(0); - const showSortOptions = (e) => { - setAnchorSort(e.currentTarget); - }; const showPaginationOptions = (e) => { setAnchorPagination(e.currentTarget); }; - const handleMenuItemClick = (e, index) => { - setSelectedIndex(index); - const optionsTable = { - 0: "namePos", - 1: "nameRev", - 2: "timePos", - 3: "timeRev", - 4: "modifyTimePos", - 5: "modifyTimeRev", - 6: "sizePos", - 7: "sizeRes", - }; - ChangeSortMethod(optionsTable[index]); - setAnchorSort(null); + + /** change sort */ + const onChangeSort = (value) => { + ChangeSortMethod(value); }; const handlePaginationChange = (s) => { ChangePageSize(s); @@ -181,32 +155,12 @@ export default function SubActions({ isSmall, inherit }) { - - - - setAnchorSort(null)} - > - {sortOptions.map((option, index) => ( - handleMenuItemClick(event, index)} - > - {t("sortMethods." + option)} - - ))} - + onChange={onChangeSort} + /> {share && (