import { Badge, Box, IconButton, Stack, styled, Tooltip, useMediaQuery, useTheme } from "@mui/material"; import React, { forwardRef } from "react"; import { useTranslation } from "react-i18next"; import { FileResponse } from "../../../api/explorer.ts"; import { clearSelected, ContextMenuTypes } from "../../../redux/fileManagerSlice.ts"; import { useAppDispatch } from "../../../redux/hooks.ts"; import { downloadFiles } from "../../../redux/thunks/download.ts"; import { deleteFile, dialogBasedMoveCopy, openFileContextMenu, openShareDialog, renameFile, } from "../../../redux/thunks/file.ts"; import { openViewers } from "../../../redux/thunks/viewer.ts"; import useActionDisplayOpt from "../../FileManager/ContextMenu/useActionDisplayOpt.ts"; import { FileManagerIndex } from "../../FileManager/FileManager.tsx"; import { ActionButton, ActionButtonGroup } from "../../FileManager/TopBar/TopActions.tsx"; import CopyOutlined from "../../Icons/CopyOutlined.tsx"; import DeleteOutlined from "../../Icons/DeleteOutlined.tsx"; import Dismiss from "../../Icons/Dismiss.tsx"; import Download from "../../Icons/Download.tsx"; import FolderArrowRightOutlined from "../../Icons/FolderArrowRightOutlined.tsx"; import MoreHorizontal from "../../Icons/MoreHorizontal.tsx"; import Open from "../../Icons/Open.tsx"; import RenameOutlined from "../../Icons/RenameOutlined.tsx"; import ShareOutlined from "../../Icons/ShareOutlined.tsx"; export interface FileSelectedActionsProps { targets: FileResponse[]; } const StyledActionButton = styled(ActionButton)(({ theme }) => ({ // disabled "&.MuiButtonBase-root.Mui-disabled": { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightRegular, fontSize: theme.typography.body2.fontSize, }, })); const StyledActionButtonGroup = styled(ActionButtonGroup)(({ theme }) => ({ backgroundColor: theme.palette.background.default, })); const FileSelectedActions = forwardRef(({ targets }: FileSelectedActionsProps, ref: React.Ref) => { const dispatch = useAppDispatch(); const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down("sm")); const isTablet = useMediaQuery(theme.breakpoints.down("md")); const { t } = useTranslation(); const displayOpt = useActionDisplayOpt(targets, ContextMenuTypes.file); if (isMobile) { return ( dispatch( clearSelected({ index: FileManagerIndex.main, value: undefined, }), ) } > dispatch(openFileContextMenu(FileManagerIndex.main, targets[0], false, e))}> ); } return ( dispatch( clearSelected({ index: FileManagerIndex.main, value: undefined, }), ) } > theme.palette.text.primary }}> {t("application:navbar.objectsSelected", { num: targets.length, })} {!isTablet && ( {displayOpt.showOpen && ( dispatch(openViewers(0, targets[0]))}> )} {displayOpt.showDownload && ( dispatch(downloadFiles(0, targets))}> )} {displayOpt.showCopy && ( dispatch(dialogBasedMoveCopy(0, targets, true))}> )} {displayOpt.showMove && ( dispatch(dialogBasedMoveCopy(0, targets, false))}> )} {displayOpt.showRename && ( dispatch(renameFile(0, targets[0]))}> )} {displayOpt.showShare && ( dispatch(openShareDialog(0, targets[0]))}> )} {displayOpt.showDelete && ( dispatch(deleteFile(0, targets))}> )} )} dispatch(openFileContextMenu(FileManagerIndex.main, targets[0], false, e))}> ); }); export default FileSelectedActions;