feat: add create and delete file/folder functionality to editor
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 1m33s
CI / Lint & Test (pull_request) Successful in 17m8s
CI / Build Linux (pull_request) Successful in 20m45s
CI / Build Windows (cross-compile) (pull_request) Successful in 35m50s

- Add Tauri backend commands: create_file, create_directory, delete_file, delete_directory
- Add editor store functions for create/delete with auto-refresh
- Add FileContextMenu component with right-click support
- Add InputDialog component for file/folder name input
- Add ConfirmDialog component for delete confirmation
- Add Ctrl+N keyboard shortcut for new file
- Update keyboard shortcuts modal with new shortcuts
- Auto-close tabs when their files are deleted
- Auto-refresh file tree after create/delete operations
This commit is contained in:
2026-01-28 16:23:40 -08:00
committed by Naomi Carrigan
parent 392243f54f
commit d6d43a8abe
10 changed files with 660 additions and 26 deletions
+72
View File
@@ -463,6 +463,78 @@ pub async fn write_file_content(path: String, content: String) -> Result<(), Str
.map_err(|e| format!("Failed to write file: {}", e))
}
#[tauri::command]
pub async fn create_file(path: String) -> Result<(), String> {
use std::fs::File;
use std::path::Path;
let file_path = Path::new(&path);
if file_path.exists() {
return Err("File already exists".to_string());
}
File::create(file_path).map_err(|e| format!("Failed to create file: {}", e))?;
Ok(())
}
#[tauri::command]
pub async fn create_directory(path: String) -> Result<(), String> {
use std::fs;
use std::path::Path;
let dir_path = Path::new(&path);
if dir_path.exists() {
return Err("Directory already exists".to_string());
}
fs::create_dir_all(dir_path).map_err(|e| format!("Failed to create directory: {}", e))?;
Ok(())
}
#[tauri::command]
pub async fn delete_file(path: String) -> Result<(), String> {
use std::fs;
use std::path::Path;
let file_path = Path::new(&path);
if !file_path.exists() {
return Err("File does not exist".to_string());
}
if file_path.is_dir() {
return Err("Path is a directory, use delete_directory instead".to_string());
}
fs::remove_file(file_path).map_err(|e| format!("Failed to delete file: {}", e))?;
Ok(())
}
#[tauri::command]
pub async fn delete_directory(path: String) -> Result<(), String> {
use std::fs;
use std::path::Path;
let dir_path = Path::new(&path);
if !dir_path.exists() {
return Err("Directory does not exist".to_string());
}
if !dir_path.is_dir() {
return Err("Path is not a directory".to_string());
}
fs::remove_dir_all(dir_path).map_err(|e| format!("Failed to delete directory: {}", e))?;
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
+4
View File
@@ -154,6 +154,10 @@ pub fn run() {
list_directory,
read_file_content,
write_file_content,
create_file,
create_directory,
delete_file,
delete_directory,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");