mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-15 03:37:04 -04:00
Workspaces: deleting the current workspace saves after switching to Default (#696)
This commit is contained in:
1 parent
470ea7a3af
commit
765915e126
2 files changed
+17
-1
No files matched your search
@@ -1054,10 +1054,11 @@ pub fn frontend(app: &mut EffectcraftApp, ctx: &egui::Context, id: &str, p: Valu
|
||||
if app.ui.saved_workspaces.remove(&name).is_none() && !builtin {
|
||||
return Err(format!("no workspace `{name}`"));
|
||||
}
|
||||
app.store_saved_workspaces();
|
||||
// Leave the deleted workspace first: a current workspace needs a definition.
|
||||
if app.ui.workspace == name {
|
||||
app.set_workspace("Default");
|
||||
}
|
||||
app.store_saved_workspaces();
|
||||
return Ok(json!({"deleted": name}));
|
||||
}
|
||||
if let Some(new) = p.get("rename").and_then(Value::as_str).map(str::trim).filter(|n| !n.is_empty() && *n != name) {
|
||||
|
||||
@@ -330,3 +330,18 @@ fn unowned_tab_keeps_the_timeline_mini_flowchart_shortcut() {
|
||||
output.textures_delta.clear();
|
||||
assert!(app.ui.mini_flowchart.is_some(), "an unowned Tab still invokes the application binding");
|
||||
}
|
||||
|
||||
/// Deleting the current workspace writes the file straight away (it used to be rejected for
|
||||
/// having no definition until the next frame retried).
|
||||
#[test]
|
||||
fn deleting_the_current_workspace_saves_immediately() {
|
||||
let store = Arc::new(MemoryConfig::default());
|
||||
let mut app = EffectcraftApp::new(Session { config: Some(store.clone()), ..Default::default() });
|
||||
let ctx = egui::Context::default();
|
||||
effectcraft_ui_egui::menus::invoke(&mut app, &ctx, "window.saveWorkspaceAs", json!({"name": "Gone"})).unwrap();
|
||||
effectcraft_ui_egui::menus::invoke(&mut app, &ctx, "window.editWorkspaces", json!({"name": "Gone", "delete": true})).unwrap();
|
||||
assert_eq!(app.ui.workspace, "Default");
|
||||
assert!(effectcraft_ui_egui::control::inspect(&app, &ctx)["workspaceStorageError"].is_null());
|
||||
let text = store.read("workspaces.json").unwrap();
|
||||
assert!(!text.contains("Gone"), "the deleted workspace must be gone from the file: {text}");
|
||||
}
|
||||
Reference in new issue
Block a user