feat(flows): native file dialog for flow file inputs
Some checks failed
Security / Security check (push) Failing after 2s
Some checks failed
Security / Security check (push) Failing after 2s
Wires the editor's new onPickFile host callback to file_picker (withData: the editor receives name + bytes, never a raw path). Pins chain_studio_flow_editor to v0.23.0. No more typing absolute paths to feed a flow a file. Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
parent
065939be74
commit
adb8d3f914
3 changed files with 17 additions and 2 deletions
|
|
@ -11,6 +11,7 @@
|
||||||
// need to know what's inside the editor any more.
|
// need to know what's inside the editor any more.
|
||||||
|
|
||||||
import 'package:chain_studio_flow_editor/chain_studio_flow_editor.dart';
|
import 'package:chain_studio_flow_editor/chain_studio_flow_editor.dart';
|
||||||
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../data/error_presentation.dart';
|
import '../data/error_presentation.dart';
|
||||||
|
|
@ -95,6 +96,17 @@ class _FlowsPageState extends State<FlowsPage> {
|
||||||
/// Hub's install API and returns the refreshed capability
|
/// Hub's install API and returns the refreshed capability
|
||||||
/// list so the editor can re-analyze without waiting for the
|
/// list so the editor can re-analyze without waiting for the
|
||||||
/// parent widget rebuild.
|
/// parent widget rebuild.
|
||||||
|
/// Native picker for a flow file input. `withData` loads the
|
||||||
|
/// bytes directly so the editor never touches the path itself
|
||||||
|
/// (sandbox-friendly: the picker grants access to exactly the
|
||||||
|
/// chosen file).
|
||||||
|
Future<PickedFileData?> _pickFlowInputFile() async {
|
||||||
|
final picked = await FilePicker.pickFiles(withData: true);
|
||||||
|
final f = picked?.files.single;
|
||||||
|
if (f == null || f.bytes == null) return null;
|
||||||
|
return PickedFileData(fileName: f.name, bytes: f.bytes!);
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<String>?> _onInstallCapability(String capability) async {
|
Future<List<String>?> _onInstallCapability(String capability) async {
|
||||||
// The analyzer hands us the full `use:` value (e.g. `debug.echo@^0`).
|
// The analyzer hands us the full `use:` value (e.g. `debug.echo@^0`).
|
||||||
// The hub resolves install sources by bare capability name; the
|
// The hub resolves install sources by bare capability name; the
|
||||||
|
|
@ -167,6 +179,9 @@ class _FlowsPageState extends State<FlowsPage> {
|
||||||
onInstallCapability: _onInstallCapability,
|
onInstallCapability: _onInstallCapability,
|
||||||
onAddModuleSource: _onAddModuleSource,
|
onAddModuleSource: _onAddModuleSource,
|
||||||
activeProject: Workspace.instance.activeSlug,
|
activeProject: Workspace.instance.activeSlug,
|
||||||
|
// Native file dialog for the Run tab's file inputs —
|
||||||
|
// nobody should have to type an absolute path by hand.
|
||||||
|
onPickFile: _pickFlowInputFile,
|
||||||
// The file wins for the run; accepting the switch only
|
// The file wins for the run; accepting the switch only
|
||||||
// aligns the workspace view to the file's project.
|
// aligns the workspace view to the file's project.
|
||||||
onSwitchToFileProject: (slug) =>
|
onSwitchToFileProject: (slug) =>
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ packages:
|
||||||
path: "../fai_chain_studio_flow_editor"
|
path: "../fai_chain_studio_flow_editor"
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "0.22.0"
|
version: "0.23.0"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ dependencies:
|
||||||
# Tag-pinned so a CI (override-free) build is reproducible and an
|
# Tag-pinned so a CI (override-free) build is reproducible and an
|
||||||
# editor push can't retroactively change what a Studio release
|
# editor push can't retroactively change what a Studio release
|
||||||
# builds against. Bump this in lockstep with the editor tag.
|
# builds against. Bump this in lockstep with the editor tag.
|
||||||
ref: v0.22.0
|
ref: v0.23.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue