From 93c8196934888bb58064f0ae46aa55fe0ca34b00 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 16:15:31 -0800 Subject: [PATCH] Enable Graph Data Import for browser file contents --- crates/ui-egui/src/dialogs/graph_data.rs | 26 ++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/graph_data.rs b/crates/ui-egui/src/dialogs/graph_data.rs index ffcc511501..9498b881c7 100644 --- a/crates/ui-egui/src/dialogs/graph_data.rs +++ b/crates/ui-egui/src/dialogs/graph_data.rs @@ -391,9 +391,10 @@ fn graph_grid(app: &mut VectorcraftApp, graph: Option) -> Result bool { - file_asks::can(app, craft::host::PickKind::Open) && app.services.read.is_some() + file_asks::can(app, craft::host::PickKind::Open) + && (app.host.files().browser_saves() || app.services.read_head.is_some() || app.services.read.is_some()) } /// Import Data's answer: a tab-separated text file's rows into the sheet that asked for it. @@ -978,6 +979,27 @@ mod tests { assert_eq!(at(&h, 0, 1), "c"); } + #[test] + fn browser_graph_data_import_reads_picked_bytes_without_a_path_reader() { + let (mut app, _) = app_with(",original\nQ1,1", "column"); + app.services.read = None; + app.services.read_head = None; + let files = Arc::new(ScriptedFiles::held().in_browser()); + app.host.with_files(files.clone()).install(app.ui_ctx.as_ref().unwrap()); + app.host = Arc::new(app.host.with_files(files.clone())); + open(&mut app).unwrap(); + let mut h = harness(app); + h.run_steps(4); + h.get_by_label("Import Data…").click(); + h.run_steps(3); + assert_eq!(files.open(), 1, "the browser can open the Import Data picker"); + files.answer(Picked::Contents(vec![("data.txt".into(), b"\timported\nQ2\t8".to_vec())])); + h.run_steps(4); + assert_eq!(read(h.state(), |d| cell_of(&d.sheet.grid, 0, 1)), "imported"); + assert_eq!(read(h.state(), |d| cell_of(&d.sheet.grid, 1, 0)), "Q2"); + assert_eq!(read(h.state(), |d| cell_of(&d.sheet.grid, 1, 1)), "8"); + } + #[test] fn graph_data_import_keeps_late_answers_out_of_a_reopened_sheet() { let (mut app, _) = app_with(",first\nQ1,1", "column");