forked from kaitai-io/kaitai_struct_webide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added rename action, refactor of how paths are handled by FileSystemPath
- Loading branch information
Showing
25 changed files
with
311 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {FileSystemPath} from "../FileSystemsTypes"; | ||
import {useFileSystems} from "../Store/FileSystemsStore"; | ||
import {useAppStore} from "../../../Stores/AppStore"; | ||
|
||
const updateCurrentlyLoadedFilesIfNeeded = (currentPath: FileSystemPath, newPath: FileSystemPath) => { | ||
const fileSystemAppStore = useAppStore(); | ||
if (fileSystemAppStore.selectedKsyInfo.isPartOf(currentPath)) { | ||
const newCurrentlyLoadedFilePath = fileSystemAppStore.selectedKsyInfo.replacePathPart(currentPath, newPath); | ||
fileSystemAppStore.updateSelectedKsyFile(newCurrentlyLoadedFilePath); | ||
} | ||
|
||
if (fileSystemAppStore.selectedBinaryInfo.isPartOf(currentPath)) { | ||
const newCurrentlyLoadedFilePath = fileSystemAppStore.selectedBinaryInfo.replacePathPart(currentPath, newPath); | ||
fileSystemAppStore.updateSelectedKsyFile(newCurrentlyLoadedFilePath); | ||
} | ||
}; | ||
|
||
export const FileTreeMoveAction = async (oldPath: FileSystemPath, newPath: FileSystemPath) => { | ||
const fileSystemsStore = useFileSystems(); | ||
await fileSystemsStore.move(oldPath, newPath); | ||
updateCurrentlyLoadedFilesIfNeeded(oldPath, newPath); | ||
fileSystemsStore.selectPath(newPath) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Components/FileTree/ContextMenu/Actions/FileTreeCtxActionRename.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {TreeNodeDisplay} from "../../FileSystemVisitors/FileSystemFileTreeMapper"; | ||
import {MenuItem} from "@imengyu/vue3-context-menu/lib/ContextMenuDefine"; | ||
import {h} from "vue"; | ||
import {PencilIcon} from "@heroicons/vue/16/solid"; | ||
import {useTextModalInputStore} from "../../../Modals/TextInputModal/TextInputModalStore"; | ||
import {useAppStore} from "../../../../Stores/AppStore"; | ||
import {FileSystemPath} from "../../FileSystemsTypes"; | ||
import {FILE_SYSTEM_TYPE_KAITAI} from "../../FileSystems/KaitaiFileSystem"; | ||
import {FileTreeMoveAction} from "../../Actions/FileTreeMoveAction"; | ||
|
||
export const FileTreeCtxActionRename = (item: TreeNodeDisplay): MenuItem => { | ||
|
||
|
||
const action = async () => { | ||
const modalInputStore = useTextModalInputStore(); | ||
modalInputStore.open({ | ||
title: "Rename", | ||
initValue: item.fileName, | ||
onAccept: async (newName) => { | ||
const newFullPathString = item.fullPath.replace(item.fileName, newName); | ||
const oldPath = FileSystemPath.fromFullPathWithStore(item.fullPathWithStore); | ||
const newPath = FileSystemPath.of(item.storeId, newFullPathString); | ||
|
||
FileTreeMoveAction(oldPath, newPath); | ||
}, | ||
}); | ||
}; | ||
|
||
return { | ||
label: "Rename", | ||
onClick: action, | ||
// hidden: [TreeNodeDisplayType.KSY_FILE].indexOf(item.type) === -1, | ||
customClass: "context-menu-item", | ||
disabled: item.storeId === FILE_SYSTEM_TYPE_KAITAI || item.fullPath === "", | ||
icon: () => h(PencilIcon), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.