mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
Directory View Parent Directory Button (#805)
Add a button in the directory view to easily navigate to the parent of the current directory.
This commit is contained in:
parent
7708db7060
commit
4ff247d2f2
@ -287,7 +287,8 @@ export class PreviewModel implements ViewModel {
|
||||
return null;
|
||||
}
|
||||
const mimeType = util.jotaiLoadableValue(get(this.fileMimeTypeLoadable), "");
|
||||
if (mimeType == "directory") {
|
||||
const metaPath = get(this.metaFilePath);
|
||||
if (mimeType == "directory" && metaPath == "/") {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
@ -492,29 +493,24 @@ export class PreviewModel implements ViewModel {
|
||||
}
|
||||
|
||||
async goParentDirectory() {
|
||||
const blockMeta = globalStore.get(this.blockAtom)?.meta;
|
||||
const metaPath = globalStore.get(this.metaFilePath);
|
||||
const fileInfo = await globalStore.get(this.statFile);
|
||||
if (fileInfo == null) {
|
||||
return;
|
||||
this.updateOpenFileModalAndError(false);
|
||||
return true;
|
||||
}
|
||||
let newPath: string = null;
|
||||
if (!fileInfo.isdir) {
|
||||
newPath = fileInfo.dir;
|
||||
} else {
|
||||
const lastSlash = fileInfo.dir.lastIndexOf("/");
|
||||
newPath = fileInfo.dir.slice(0, lastSlash);
|
||||
if (newPath.indexOf("/") == -1) {
|
||||
return;
|
||||
}
|
||||
const conn = globalStore.get(this.connection);
|
||||
try {
|
||||
const newFileInfo = await RpcApi.RemoteFileJoinCommand(WindowRpcClient, [fileInfo.dir, ".."], {
|
||||
route: makeConnRoute(conn),
|
||||
});
|
||||
console.log(newFileInfo.path);
|
||||
this.updateOpenFileModalAndError(false);
|
||||
this.goHistory(newFileInfo.path);
|
||||
refocusNode(this.blockId);
|
||||
} catch (e) {
|
||||
globalStore.set(this.openFileError, e.message);
|
||||
console.error("Error opening file", [fileInfo.dir, ".."], e);
|
||||
}
|
||||
const updateMeta = historyutil.goHistory("file", metaPath, newPath, blockMeta);
|
||||
if (updateMeta == null) {
|
||||
return;
|
||||
}
|
||||
updateMeta.edit = false;
|
||||
const blockOref = WOS.makeORef("block", this.blockId);
|
||||
services.ObjectService.UpdateObjectMeta(blockOref, updateMeta);
|
||||
}
|
||||
|
||||
goHistoryBack() {
|
||||
|
Loading…
Reference in New Issue
Block a user