diff --git a/frontend/app/view/preview/preview-directory.tsx b/frontend/app/view/preview/preview-directory.tsx index 0940ba43b3..d4a2eace4f 100644 --- a/frontend/app/view/preview/preview-directory.tsx +++ b/frontend/app/view/preview/preview-directory.tsx @@ -603,6 +603,14 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) { modtime: new Date().getTime(), mimetype: "directory", }); + } else if (!finfo?.dir && finfo?.path) { + entries.unshift({ + name: "..", + path: "", + isdir: true, + modtime: new Date().getTime(), + mimetype: "directory", + }); } } catch (e) { console.error("Directory Read Error", e); diff --git a/frontend/app/view/preview/preview-model.tsx b/frontend/app/view/preview/preview-model.tsx index 8315e48b2a..b9c69f2d07 100644 --- a/frontend/app/view/preview/preview-model.tsx +++ b/frontend/app/view/preview/preview-model.tsx @@ -31,6 +31,10 @@ const BOOKMARKS: { label: string; path: string }[] = [ { label: "Root", path: "/" }, ]; +if (window.navigator?.platform?.startsWith("Win")) { + BOOKMARKS.push({ label: "Drives", path: "" }); +} + const MaxFileSize = 1024 * 1024 * 10; // 10MB const MaxCSVSize = 1024 * 1024 * 1; // 1MB @@ -207,7 +211,7 @@ export class PreviewModel implements ViewModel { return { elemtype: "iconbutton", icon: "folder-open", - longClick: (e: React.MouseEvent) => { + click: (e: React.MouseEvent) => { const menuItems: ContextMenuItem[] = BOOKMARKS.map((bookmark) => ({ label: `Go to ${bookmark.label} (${bookmark.path})`, click: () => this.goHistory(bookmark.path), @@ -315,7 +319,7 @@ export class PreviewModel implements ViewModel { } const mimeType = jotaiLoadableValue(get(this.fileMimeTypeLoadable), ""); const metaPath = get(this.metaFilePath); - if (mimeType == "directory" && metaPath == "/") { + if (mimeType == "directory" && (metaPath == "/" || metaPath == "")) { return null; } return { @@ -379,7 +383,7 @@ export class PreviewModel implements ViewModel { }); this.metaFilePath = atom((get) => { const file = get(this.blockAtom)?.meta?.file; - if (isBlank(file)) { + if (file == null) { return "~"; } return file; diff --git a/frontend/util/historyutil.ts b/frontend/util/historyutil.ts index 73e4da201e..a41b0f7bef 100644 --- a/frontend/util/historyutil.ts +++ b/frontend/util/historyutil.ts @@ -5,22 +5,24 @@ import * as util from "@/util/util"; const MaxHistory = 20; -// this needs to be fixed for windows function getParentDirectory(path: string): string { if (util.isBlank(path) == null) { - // this not great, ideally we'd never be passed a null path return "/"; } - if (path == "/") { - return "/"; + if (path == "/" || path == "") { + return path; } - const splitPath = path.split("/"); + const separator = path.includes("\\") ? "\\" : "/"; + const splitPath = path.split(separator); splitPath.pop(); - if (splitPath.length == 1 && splitPath[0] == "") { - return "/"; + if (splitPath.length == 0 || (splitPath.length == 1 && splitPath[0] == "")) { + return separator == "\\" ? path.substring(0, 3) : "/"; + } + const joined = splitPath.join(separator); + if (separator == "\\" && joined.length == 2 && joined[1] == ":") { + return joined + "\\"; } - const newPath = splitPath.join("/"); - return newPath; + return joined; } function goHistoryBack(curValKey: "url" | "file", curVal: string, meta: MetaType, backToParent: boolean): MetaType { diff --git a/frontend/util/waveutil.ts b/frontend/util/waveutil.ts index 4d0f5952fc..7944e54d09 100644 --- a/frontend/util/waveutil.ts +++ b/frontend/util/waveutil.ts @@ -91,5 +91,8 @@ export function computeBgStyleFromMeta(meta: Omit