diff --git a/src/components/App.tsx b/src/components/App.tsx index 23e1829d..aecbfdd6 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -62,14 +62,11 @@ const App = observer(() => { status: activeCache.status, path: activeCache.path, selectedLength: activeCache.selected.length, - // enable when FsZip is merged - isReadonly: false, - isIndirect: false, historyLength: activeCache.history.length, historyCurrent: activeCache.current, isRoot: API.isRoot(activeCache.path), - // isReadonly: activeCache.getFS().options.readonly, - // isIndirect: activeCache.getFS().options.indirect, + isReadonly: fs.options.readonly, + isIndirect: fs.options.indirect, isOverlayOpen: refIsOverlayOpen.current, activeViewTabNums: activeView.caches.length, isExplorer: appState.isExplorer, @@ -77,7 +74,6 @@ const App = observer(() => { filesLength: activeCache.files.length, clipboardLength: appState.clipboard.files.length, activeViewId: activeView.viewId, - // missing: about opened, tab: is it needed? } }, [appState]) diff --git a/src/components/menus/FileContextMenu.tsx b/src/components/menus/FileContextMenu.tsx index b93bae35..6b12b89b 100644 --- a/src/components/menus/FileContextMenu.tsx +++ b/src/components/menus/FileContextMenu.tsx @@ -14,11 +14,14 @@ const FileContextMenu = ({ fileUnderMouse }: Props) => { const { appState } = useStores('appState') const clipboard = appState.clipboard const cache = appState.getActiveCache() + const isReadonly = cache.options.readonly - // TODO: disable delete/paste when cahce.fs.readonly is true const numFilesInClipboard = clipboard.files.length const isInSelection = fileUnderMouse && !!cache.selected.find((file) => sameID(file.id, fileUnderMouse.id)) - const isPasteEnabled = numFilesInClipboard && ((!fileUnderMouse && !cache.error) || fileUnderMouse?.isDir) + // FIXME: if fileUnderMouse is a folder, we could paste inside that folder. Right now paste doesn't care about + // where click happens: it just uses current cache as target. + // ((!fileUnderMouse && !cache.error) || fileUnderMouse?.isDir) + const isPasteEnabled = numFilesInClipboard && !isReadonly const onCopy = () => { clipboard.setClipboard(cache, !isInSelection ? [fileUnderMouse] : undefined) @@ -59,7 +62,7 @@ const FileContextMenu = ({ fileUnderMouse }: Props) => { icon="delete" intent={Intent.DANGER} text={t('APP_MENUS.DELETE')} - disabled={!fileUnderMouse} + disabled={!fileUnderMouse || isReadonly} onClick={onDelete} /> diff --git a/src/services/plugins/FsZip.ts b/src/services/plugins/FsZip.ts index 154ca74f..aacad8c8 100644 --- a/src/services/plugins/FsZip.ts +++ b/src/services/plugins/FsZip.ts @@ -1,7 +1,5 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import StreamZip, { StreamZipAsync, ZipEntry } from 'node-stream-zip' -import type { ReadStream, BigIntStats } from 'fs' -import { Transform, TransformCallback } from 'stream' import * as path from 'path' import { FsApi, FileDescriptor, Credentials, Fs, filetype, MakeId } from '$src/services/Fs' @@ -16,10 +14,6 @@ const getZipPathRegEx = /(?<=\.zip).*/i // we accept Windows style paths (eg. C:\foo...) and unix paths (eg. /foo or ./foo) const isRoot = (isWin && /((([a-zA-Z]\:)(\\)*)|(\\\\))$/) || /^\/$/ -const progressFunc = throttle((progress: (bytes: number) => void, bytesRead: number) => { - progress(bytesRead) -}, 400) - export const checkDirectoryName = (dirName: string) => !!!dirName.match(invalidDirChars) && dirName !== '/' export interface ZipMethods { diff --git a/src/state/fileState.ts b/src/state/fileState.ts index 366aa7e2..2db1947b 100644 --- a/src/state/fileState.ts +++ b/src/state/fileState.ts @@ -722,4 +722,8 @@ export class FileState { setViewMode(newViewMode: ViewModeName) { this.viewmode = newViewMode } + + get options() { + return this.fs.options + } }