import { ReactElement } from 'react' import type { FileInfo, DriveInfo } from '@solarpunkltd/file-manager-lib' import { ConfirmModal } from '../ConfirmModal/ConfirmModal' import { Tooltip } from '../Tooltip/Tooltip' import { DeleteFileModal } from '../DeleteFileModal/DeleteFileModal' import { DestroyDriveModal } from '../DestroyDriveModal/DestroyDriveModal' import { FileAction } from '../../constants/transfers' import { TOOLTIPS } from '../../constants/tooltips' interface FileBrowserModalsProps { showDeleteModal: boolean selectedFiles: FileInfo[] fileCountText: string currentDrive: DriveInfo | null confirmBulkForget: boolean confirmBulkRestore: boolean showDestroyDriveModal: boolean pendingCancelUpload: string | null onDeleteCancel: () => void onDeleteProceed: (action: FileAction) => void onForgetConfirm: () => Promise onForgetCancel: () => void onRestoreConfirm: () => Promise onRestoreCancel: () => void onDestroyCancel: () => void onDestroyConfirm: () => Promise onCancelUploadConfirm: () => void onCancelUploadCancel: () => void } export function FileBrowserModals({ showDeleteModal, selectedFiles, fileCountText, currentDrive, confirmBulkForget, confirmBulkRestore, showDestroyDriveModal, pendingCancelUpload, onDeleteCancel, onDeleteProceed, onForgetConfirm, onForgetCancel, onRestoreConfirm, onRestoreCancel, onDestroyCancel, onDestroyConfirm, onCancelUploadConfirm, onCancelUploadCancel, }: FileBrowserModalsProps): ReactElement { return ( <> {showDeleteModal && ( f.name)} currentDriveName={currentDrive?.name} onCancelClick={onDeleteCancel} onProceed={onDeleteProceed} /> )} {confirmBulkForget && ( Forget permanently? } message={ <> This removes {selectedFiles.length} {fileCountText} from your view.
The data remains on Swarm until the drive expires. } confirmLabel="Forget" cancelLabel="Cancel" onConfirm={onForgetConfirm} onCancel={onForgetCancel} /> )} {confirmBulkRestore && ( Restore from trash? } message={ <> This will restore {selectedFiles.length} {fileCountText} from trash. } confirmLabel="Restore" cancelLabel="Cancel" onConfirm={onRestoreConfirm} onCancel={onRestoreCancel} /> )} {showDestroyDriveModal && currentDrive && ( )} {pendingCancelUpload && ( Stopping now will cancel the network request. Data already transmitted cannot be reverted.{' '} We will try our best to clean up the transmitted data.
To remove any (remaining) cancelled items from your browser view later, use{' '} Right-click → Delete → Forget. } confirmLabel="Cancel upload" cancelLabel="Keep uploading" onConfirm={onCancelUploadConfirm} onCancel={onCancelUploadCancel} /> )} ) }