@setoelkahfi / svara / commits / 479a442

feat: rename modal opens on rename file

mellbacon committed Jun 25, 2023 at 14:23 UTC 479a4424584094f30ab8267070b6100f1cc2027a
2 files changed +12 -3
src/lib/FileTree/FileTreeList.svelte
+6 -2
@@ -12,7 +12,7 @@
12 import ContextMenu from "../utility/ContextMenu.svelte";
13 import { createFile, createFolder, moveFile, moveToTrash, openInExplorer } from "../File";
14 import { clipboard } from "@tauri-apps/api";
15 - import { openInputModal } from "../../App.svelte";
15 + import { openInputModal, openRenameModal } from "../../App.svelte";
16 import { path as p } from "@tauri-apps/api";
17
18 export let root = false;
@@ -49,7 +49,11 @@
49 {name: "Paste", shortcut: "Ctrl + X", disabled: true, action: () => {console.warn("Feature not implemented yet.")}},
50 {name: "Copy Filename", shortcut: "", action: async () => {await clipboard.writeText(name)}},
51 {name: "Copy Absolute Path", shortcut: "", action: async () => {await clipboard.writeText(path)}},
52 - {name: "Rename...", shortcut: "F2", disabled: true, action: () => {console.warn("Feature not implemented yet.")}},
52 + {name: "Rename...", shortcut: "F2", action: () => {openRenameModal(`Rename ${name}`,
53 + `Give a new name to ${name}/`, [
54 + {name: "Rename", action: () => {}},
55 + {name: "Cancel", action: () => {}}
56 + ])}},
57 {name: "Delete", disabled: isroot, shortcut: "Delete", action: async () => {await moveToTrash(path)}}
58 ]
59
src/lib/FileTree/FileTreeNode.svelte
+6 -1
@@ -21,6 +21,7 @@
21 import { moveToTrash, openInExplorer } from "../File";
22 import { addEditorTab } from "../EditorTabList.svelte";
23 import { clipboard } from "@tauri-apps/api";
24 + import { openRenameModal } from "../../App.svelte";
25
26 export let id;
27 export let name;
@@ -40,7 +41,11 @@
41 {name: "Copy Filename", shortcut: "", action: async () => {await clipboard.writeText(name)}},
42 {name: "Copy Absolute Path", shortcut: "", action: async () => {await clipboard.writeText(path)}},
43 {name: "Edit", shortcut: "", action: () => {addEditorTab(path, name)}},
43 - {name: "Rename...", shortcut: "F2", disabled: true, action: () => {console.warn("Feature not implemented yet.")}},
44 + {name: "Rename...", shortcut: "F2", disabled: true, action: () => {openRenameModal(`Rename ${name}`,
45 + `Give a new name to ${name}`, [
46 + {name: "Rename", action: () => {}},
47 + {name: "Cancel", action: () => {}}
48 + ])}},
49 {name: "Delete", shortcut: "Delete", action: async () => {await moveToTrash(path)}}
50 ]
51