mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-21 09:26:43 +00:00
Actions panel: Save Actions… saves the selected set (CodeRabbit review on crates/ui-egui/src/panels/actions.rs:1168)
A click on a set's folder row clears the selected action, so Save Actions… fell back to the first action's set and could save another set. It now saves the selected set when no action is selected, and keeps the first action's set as the fallback when neither is selected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6c24702131
commit
a4582df1d0
2 files changed
+35
-3
No files matched your search
@@ -428,10 +428,12 @@ fn load_dialog(app: &mut PhotocraftApp) -> Result<Value, String> {
|
||||
app.pick_file_bytes_filtered(&["atn"], |app, name, bytes| load_bytes(app, &name, &bytes))
|
||||
}
|
||||
|
||||
/// Save Actions…: the selected action's set (every action of it), or every action when none
|
||||
/// came from a set, as a `.atn` file Photoshop loads.
|
||||
/// Save Actions…: the selected action's set (every action of it), else the selected set folder,
|
||||
/// or every action when none came from a set, as a `.atn` file Photoshop loads.
|
||||
fn save_dialog(app: &mut PhotocraftApp, set: Option<String>) -> Result<Value, String> {
|
||||
let set = set.or_else(|| selected_action(app).and_then(|a| a.set.clone()));
|
||||
let selected_set = app.ui.actions.selected.is_none().then(|| app.ui.actions.selected_set.clone()).flatten();
|
||||
let selected_set = selected_set.filter(|set| photocraft_engine::actions_edit_cmds::set_names(&app.session).contains(set));
|
||||
let set = set.or(selected_set).or_else(|| selected_action(app).and_then(|a| a.set.clone()));
|
||||
let params = match &set {
|
||||
Some(set) => json!({"set": set, "skipUnsupported": true}),
|
||||
None => json!({"skipUnsupported": true}),
|
||||
|
||||
@@ -723,6 +723,36 @@ fn start_recording_with_a_set_selected_records_a_new_action_into_it() {
|
||||
assert_eq!(list[1].set.as_deref(), Some("Web"));
|
||||
}
|
||||
|
||||
/// Save Actions… after a click on set B's folder row saves set B, not the first action's set.
|
||||
#[test]
|
||||
fn save_actions_with_a_set_selected_saves_that_set() {
|
||||
use egui_kittest::{Harness, kittest::Queryable};
|
||||
let (file_dialog, asked) = crate::file_dialog::fake(vec![None]);
|
||||
let services = crate::Services { file_dialog: Some(file_dialog), ..Default::default() };
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), services);
|
||||
app.run("file.new", json!({"width": 8, "height": 8})).unwrap();
|
||||
for (name, set) in [("Sharpen", "Retouch"), ("Resize", "Web")] {
|
||||
let mut action = Action::new(name, vec![("layer.new.layer".into(), json!({}))]);
|
||||
action.set = Some(set.into());
|
||||
app.session.actions.list.push(action);
|
||||
}
|
||||
let mut h = Harness::builder().with_size(vec2(360.0, 600.0)).build_ui_state(
|
||||
|ui, app| {
|
||||
panel_menu(app, ui);
|
||||
panel(app, ui);
|
||||
},
|
||||
app,
|
||||
);
|
||||
h.run_steps(2);
|
||||
h.get_by_label("Web").click();
|
||||
h.run_steps(2);
|
||||
assert_eq!((h.state().ui.actions.selected, h.state().ui.actions.selected_set.as_deref()), (None, Some("Web")));
|
||||
h.get_by_label("Save Actions…").click();
|
||||
h.run_steps(2);
|
||||
h.state_mut().poll_file_dialog(&egui::Context::default(), None);
|
||||
assert!(matches!(asked.borrow().as_slice(), [crate::file_dialog::FileDialogRequest::Save { suggested }] if suggested == "Web.atn"), "{:?}", asked.borrow());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn moving_an_action_next_to_another_set_joins_it() {
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
|
||||
Reference in new issue
Block a user