Four UX threads stitched into one commit. Each pulls Studio toward Stefan's "zero-learning-curve" goal — the feedback that earned its own memory entry. 1. Flow-Runnability-Indikator ───────────────────────── The Flows tab now fetches `listFlows` and `listModules` in parallel. Each card compares the flow's `requiredCapabilities` against the installed-modules' capability set; rows with missing modules show a "Needs: text.extract@^0" red pill row beneath the path and have their Run button greyed out + tooltip "Install the missing modules first." Operators stop hitting Run → cryptic hub error → frustration. 2. Welcome-Checklist Celebration ───────────────────────────── Once all four checklist signals flip to done, an `_AllDoneCelebration` card replaces the bare "All four steps complete" + Hide button. Three concrete next-threads with action buttons: "Read the audit log", "Set up the daily Today story" (opens the Flows / Today doc inline via `_DocReaderSheet`), and "Build your own module" (opens the architecture doc). Operator who just got set up sees what to do next instead of an empty "what now?" feeling. 3. Audit-Page Time-Bucket Headers + Flow-Run Detail ──────────────────────────────────────────────── The flat event list grows tiny "TODAY / YESTERDAY / EARLIER THIS WEEK / OLDER" section headers — bucket is computed in the operator's local timezone so an event at 23:55 yesterday in Berlin doesn't end up in "today" because UTC happened to spill into a new day. Plus: the event-detail dialog gains a "View flow run" action when the picked event has a `flow_execution`. It opens a drill-down that lists every event in the already-fetched 100-event window sharing the same execution id, sorted ascending — the operator reads the run from step.started top to flow.completed bottom. 4. Approvals-Batch-Aktionen ──────────────────────── Each pending approval card grows a checkbox. When ≥1 selected, a floating action bar appears at the bottom with "N selected · Select all · Clear · Reject all · Approve all". The parent loops sequentially through the per-record SDK calls so a partial failure produces "X done, Y failed" instead of a confusing all-or-nothing rollback. Reject prompts for a reason once and applies to the whole picked set. 13 new ARB keys cover the strings the four features needed. Studio's tests stay green. Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
733 lines
23 KiB
Dart
733 lines
23 KiB
Dart
import 'dart:io';
|
|
import 'dart:typed_data';
|
|
|
|
import 'package:fai_dart_sdk/fai_dart_sdk.dart' show FlowInputDef;
|
|
import 'package:file_picker/file_picker.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../data/hub.dart';
|
|
import '../l10n/app_localizations.dart';
|
|
import '../theme/theme.dart';
|
|
import '../theme/tokens.dart';
|
|
import '../widgets/widgets.dart';
|
|
|
|
class FlowsPage extends StatefulWidget {
|
|
const FlowsPage({super.key});
|
|
|
|
@override
|
|
State<FlowsPage> createState() => _FlowsPageState();
|
|
}
|
|
|
|
class _FlowsPageState extends State<FlowsPage> {
|
|
late Future<_FlowsBundle> _future;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_future = _load();
|
|
}
|
|
|
|
/// Pulls the saved flows AND the installed-modules list in
|
|
/// parallel so the page can compute "is this flow runnable"
|
|
/// per row from the same data the Run button gates on.
|
|
Future<_FlowsBundle> _load() async {
|
|
final results = await Future.wait([
|
|
HubService.instance.listFlows(),
|
|
HubService.instance.listModules().catchError((_) => <ModuleSummary>[]),
|
|
]);
|
|
return _FlowsBundle(
|
|
flows: results[0] as List<SavedFlow>,
|
|
installedCapabilities: (results[1] as List<ModuleSummary>)
|
|
.expand((m) => m.capabilities)
|
|
.toSet(),
|
|
);
|
|
}
|
|
|
|
void _refresh() => setState(() {
|
|
_future = _load();
|
|
});
|
|
|
|
/// Returns the verbatim `use:` strings whose bare capability
|
|
/// name is not provided by any installed module. The bare
|
|
/// name is everything left of the first `@`; version
|
|
/// constraints are tolerated at this stage — the hub does
|
|
/// the full resolution at run time.
|
|
List<String> _missing(SavedFlow flow, Set<String> installed) {
|
|
final out = <String>[];
|
|
for (final cap in flow.requiredCapabilities) {
|
|
final at = cap.indexOf('@');
|
|
final name = at >= 0 ? cap.substring(0, at) : cap;
|
|
if (!installed.contains(name)) out.add(cap);
|
|
}
|
|
return out;
|
|
}
|
|
|
|
Future<void> _runFlow(SavedFlow flow) async {
|
|
final inputs = await _FlowInputDialog.show(context, flow);
|
|
if (inputs == null) return;
|
|
if (!mounted) return;
|
|
showDialog<void>(
|
|
context: context,
|
|
barrierDismissible: false,
|
|
builder: (_) => _FlowRunDialog(
|
|
flow: flow,
|
|
textInputs: inputs.textInputs,
|
|
fileInputs: inputs.fileInputs,
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l = AppLocalizations.of(context)!;
|
|
return Scaffold(
|
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
|
appBar: AppBar(
|
|
title: Text(l.flowsTitle),
|
|
actions: [
|
|
IconButton(
|
|
icon: const Icon(Icons.refresh, size: 18),
|
|
tooltip: l.flowsReloadTooltip,
|
|
onPressed: _refresh,
|
|
),
|
|
const SizedBox(width: FaiSpace.sm),
|
|
],
|
|
),
|
|
body: FutureBuilder<_FlowsBundle>(
|
|
future: _future,
|
|
builder: (context, snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
if (snapshot.hasError) {
|
|
return FaiEmptyState(
|
|
icon: Icons.cloud_off_outlined,
|
|
iconColor: Theme.of(context).colorScheme.error,
|
|
title: l.hubUnreachable,
|
|
hint: l.hubUnreachableHint,
|
|
action: FilledButton.tonal(
|
|
onPressed: _refresh,
|
|
child: Text(l.buttonRetry),
|
|
),
|
|
);
|
|
}
|
|
final bundle = snapshot.data ?? const _FlowsBundle.empty();
|
|
final flows = bundle.flows;
|
|
if (flows.isEmpty) {
|
|
return FaiEmptyState(
|
|
icon: Icons.account_tree_outlined,
|
|
title: l.flowsNoneTitle,
|
|
hint: l.flowsNoneHint,
|
|
);
|
|
}
|
|
return ListView.separated(
|
|
padding: const EdgeInsets.all(FaiSpace.xl),
|
|
itemCount: flows.length,
|
|
separatorBuilder: (_, _) => const SizedBox(height: FaiSpace.md),
|
|
itemBuilder: (context, i) {
|
|
final flow = flows[i];
|
|
final missing = _missing(flow, bundle.installedCapabilities);
|
|
return _FlowCard(
|
|
flow: flow,
|
|
missingCapabilities: missing,
|
|
onRun: missing.isEmpty ? () => _runFlow(flow) : null,
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Snapshot of everything the Flows page needs in one render
|
|
/// pass: the saved flows themselves and the set of installed
|
|
/// capability names. Stored as a single Future so the
|
|
/// FutureBuilder transitions atomically (no flicker between
|
|
/// "flows loaded but modules pending").
|
|
class _FlowsBundle {
|
|
final List<SavedFlow> flows;
|
|
final Set<String> installedCapabilities;
|
|
const _FlowsBundle({
|
|
required this.flows,
|
|
required this.installedCapabilities,
|
|
});
|
|
const _FlowsBundle.empty()
|
|
: flows = const [],
|
|
installedCapabilities = const {};
|
|
}
|
|
|
|
class _FlowCard extends StatelessWidget {
|
|
final SavedFlow flow;
|
|
final List<String> missingCapabilities;
|
|
/// Null when the flow can't run (missing modules); the
|
|
/// Run button greys out + a tooltip points the operator
|
|
/// at the install path. Non-null otherwise.
|
|
final VoidCallback? onRun;
|
|
|
|
const _FlowCard({
|
|
required this.flow,
|
|
required this.missingCapabilities,
|
|
required this.onRun,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final l = AppLocalizations.of(context)!;
|
|
final isRunnable = missingCapabilities.isEmpty;
|
|
return FaiCard(
|
|
child: Row(
|
|
children: [
|
|
Icon(
|
|
Icons.account_tree_outlined,
|
|
size: 20,
|
|
color: theme.colorScheme.primary,
|
|
),
|
|
const SizedBox(width: FaiSpace.md),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
flow.name,
|
|
style: theme.textTheme.titleMedium?.copyWith(
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
const SizedBox(height: 2),
|
|
Text(
|
|
flow.path,
|
|
style: FaiTheme.mono(
|
|
size: 11,
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
if (!isRunnable) ...[
|
|
const SizedBox(height: FaiSpace.sm),
|
|
Wrap(
|
|
spacing: FaiSpace.xs,
|
|
runSpacing: FaiSpace.xs,
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
children: [
|
|
Text(
|
|
l.flowsMissingModulesLabel,
|
|
style: theme.textTheme.labelSmall?.copyWith(
|
|
color: theme.colorScheme.error,
|
|
letterSpacing: 0.4,
|
|
),
|
|
),
|
|
for (final cap in missingCapabilities)
|
|
FaiPill(
|
|
label: cap,
|
|
tone: FaiPillTone.danger,
|
|
monospace: true,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
FaiPill(
|
|
label: '${flow.sizeBytes} B',
|
|
tone: FaiPillTone.neutral,
|
|
monospace: true,
|
|
),
|
|
const SizedBox(width: FaiSpace.md),
|
|
Tooltip(
|
|
message: isRunnable ? '' : l.flowsRunDisabledTooltip,
|
|
child: FilledButton.icon(
|
|
onPressed: onRun,
|
|
icon: const Icon(Icons.play_arrow, size: 16),
|
|
label: Text(l.flowsRunButton),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Inputs collected by `_FlowInputDialog` and forwarded to
|
|
/// the run dialog. Text and file values arrive in separate
|
|
/// maps so the SDK can wrap each as the appropriate Payload
|
|
/// variant.
|
|
class _FlowRunInputs {
|
|
final Map<String, String> textInputs;
|
|
final Map<String, Uint8List> fileInputs;
|
|
const _FlowRunInputs({
|
|
required this.textInputs,
|
|
required this.fileInputs,
|
|
});
|
|
}
|
|
|
|
class _PickedFile {
|
|
final String name;
|
|
final Uint8List bytes;
|
|
const _PickedFile({required this.name, required this.bytes});
|
|
}
|
|
|
|
/// Run-flow input dialog. Fetches the flow's declared input
|
|
/// schema first via `getFlowDefinition`, then renders one
|
|
/// type-aware field per declared input:
|
|
///
|
|
/// * `bytes` / `file` → "Choose file" button + picked-file
|
|
/// readout. Routes through the OS
|
|
/// file dialog so sandboxed Studio
|
|
/// still gets read access to the
|
|
/// chosen file. `withData: true` so
|
|
/// the bytes flow through the
|
|
/// FilePicker result instead of a
|
|
/// path that may be unreadable.
|
|
/// * everything else → TextField. Opaque type tag is
|
|
/// shown as a pill next to the input
|
|
/// name so a flow author who picks
|
|
/// a less-common type still gets a
|
|
/// hint.
|
|
///
|
|
/// The Run button enables only when every input has a value
|
|
/// — required-field validation happens client-side before
|
|
/// the hub sees an empty inputs map.
|
|
class _FlowInputDialog extends StatefulWidget {
|
|
final SavedFlow flow;
|
|
|
|
const _FlowInputDialog({required this.flow});
|
|
|
|
static Future<_FlowRunInputs?> show(
|
|
BuildContext context,
|
|
SavedFlow flow,
|
|
) {
|
|
return showDialog<_FlowRunInputs>(
|
|
context: context,
|
|
builder: (_) => _FlowInputDialog(flow: flow),
|
|
);
|
|
}
|
|
|
|
@override
|
|
State<_FlowInputDialog> createState() => _FlowInputDialogState();
|
|
}
|
|
|
|
class _FlowInputDialogState extends State<_FlowInputDialog> {
|
|
late final Future<List<FlowInputDef>> _defFuture;
|
|
final Map<String, TextEditingController> _textControllers = {};
|
|
final Map<String, _PickedFile> _pickedFiles = {};
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_defFuture = HubService.instance.getFlowDefinition(widget.flow.name);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
for (final c in _textControllers.values) {
|
|
c.dispose();
|
|
}
|
|
super.dispose();
|
|
}
|
|
|
|
bool _isBytesType(String type) => type == 'bytes' || type == 'file';
|
|
|
|
bool _isComplete(List<FlowInputDef> defs) {
|
|
for (final d in defs) {
|
|
if (_isBytesType(d.type)) {
|
|
if (_pickedFiles[d.name] == null) return false;
|
|
} else {
|
|
final v = _textControllers[d.name]?.text.trim() ?? '';
|
|
if (v.isEmpty) return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
_FlowRunInputs _collect(List<FlowInputDef> defs) {
|
|
final textInputs = <String, String>{};
|
|
final fileInputs = <String, Uint8List>{};
|
|
for (final d in defs) {
|
|
if (_isBytesType(d.type)) {
|
|
final picked = _pickedFiles[d.name];
|
|
if (picked != null) fileInputs[d.name] = picked.bytes;
|
|
} else {
|
|
final c = _textControllers[d.name];
|
|
if (c != null) textInputs[d.name] = c.text;
|
|
}
|
|
}
|
|
return _FlowRunInputs(textInputs: textInputs, fileInputs: fileInputs);
|
|
}
|
|
|
|
Future<void> _pickFile(String inputName) async {
|
|
final result = await FilePicker.platform.pickFiles(withData: true);
|
|
if (result == null || result.files.isEmpty) return;
|
|
final f = result.files.first;
|
|
var bytes = f.bytes;
|
|
if (bytes == null && f.path != null) {
|
|
// Some Linux configurations don't honour `withData: true`
|
|
// for large files; fall back to reading via path.
|
|
try {
|
|
bytes = await File(f.path!).readAsBytes();
|
|
} catch (e) {
|
|
if (!mounted) return;
|
|
final l = AppLocalizations.of(context)!;
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(content: Text(l.flowsFileReadFailed(f.path!, '$e'))),
|
|
);
|
|
return;
|
|
}
|
|
}
|
|
if (bytes == null || !mounted) return;
|
|
setState(() {
|
|
_pickedFiles[inputName] = _PickedFile(name: f.name, bytes: bytes!);
|
|
});
|
|
}
|
|
|
|
/// Lazily ensure each text-shaped input has a controller +
|
|
/// a setState-triggering listener so the Run button reflects
|
|
/// validity as the operator types.
|
|
void _ensureTextControllers(List<FlowInputDef> defs) {
|
|
for (final d in defs) {
|
|
if (_isBytesType(d.type)) continue;
|
|
_textControllers.putIfAbsent(d.name, () {
|
|
final c = TextEditingController();
|
|
c.addListener(() {
|
|
if (mounted) setState(() {});
|
|
});
|
|
return c;
|
|
});
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final l = AppLocalizations.of(context)!;
|
|
return AlertDialog(
|
|
title: Text(l.flowsRunDialogTitle(widget.flow.name)),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(FaiRadius.md),
|
|
),
|
|
content: ConstrainedBox(
|
|
constraints: const BoxConstraints(maxWidth: 540, maxHeight: 540),
|
|
child: FutureBuilder<List<FlowInputDef>>(
|
|
future: _defFuture,
|
|
builder: (context, snap) {
|
|
if (snap.connectionState == ConnectionState.waiting) {
|
|
return Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const SizedBox(
|
|
width: 14,
|
|
height: 14,
|
|
child: CircularProgressIndicator(strokeWidth: 2),
|
|
),
|
|
const SizedBox(width: FaiSpace.sm),
|
|
Text(l.flowsLoadingDefinition),
|
|
],
|
|
);
|
|
}
|
|
if (snap.hasError) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
l.flowsDefinitionFailed,
|
|
style: theme.textTheme.bodyMedium?.copyWith(
|
|
color: theme.colorScheme.error,
|
|
),
|
|
),
|
|
const SizedBox(height: FaiSpace.sm),
|
|
FaiErrorBox(
|
|
text: snap.error.toString(),
|
|
isError: true,
|
|
maxHeight: 200,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
final defs = snap.data ?? const <FlowInputDef>[];
|
|
_ensureTextControllers(defs);
|
|
return SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
l.flowsRunDialogBody,
|
|
style: theme.textTheme.bodySmall?.copyWith(
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
const SizedBox(height: FaiSpace.md),
|
|
if (defs.isEmpty)
|
|
Text(
|
|
l.flowsNoInputs,
|
|
style: theme.textTheme.bodyMedium,
|
|
),
|
|
for (final d in defs) ...[
|
|
_InputField(
|
|
def: d,
|
|
isBytes: _isBytesType(d.type),
|
|
textController: _textControllers[d.name],
|
|
pickedFile: _pickedFiles[d.name],
|
|
onPick: () => _pickFile(d.name),
|
|
),
|
|
const SizedBox(height: FaiSpace.md),
|
|
],
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context, null),
|
|
child: Text(l.buttonCancel),
|
|
),
|
|
FutureBuilder<List<FlowInputDef>>(
|
|
future: _defFuture,
|
|
builder: (context, snap) {
|
|
final defs = snap.data ?? const <FlowInputDef>[];
|
|
final canRun = snap.hasData && _isComplete(defs);
|
|
return FilledButton.icon(
|
|
icon: const Icon(Icons.play_arrow, size: 16),
|
|
label: Text(l.flowsRunButton),
|
|
onPressed: canRun
|
|
? () => Navigator.pop(context, _collect(defs))
|
|
: null,
|
|
);
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class _InputField extends StatelessWidget {
|
|
final FlowInputDef def;
|
|
final bool isBytes;
|
|
final TextEditingController? textController;
|
|
final _PickedFile? pickedFile;
|
|
final VoidCallback onPick;
|
|
|
|
const _InputField({
|
|
required this.def,
|
|
required this.isBytes,
|
|
required this.textController,
|
|
required this.pickedFile,
|
|
required this.onPick,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final l = AppLocalizations.of(context)!;
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Text(
|
|
def.name,
|
|
style: FaiTheme.mono(
|
|
size: 12,
|
|
weight: FontWeight.w600,
|
|
color: theme.colorScheme.onSurface,
|
|
),
|
|
),
|
|
const SizedBox(width: FaiSpace.sm),
|
|
FaiPill(
|
|
label: def.type,
|
|
tone: isBytes ? FaiPillTone.warning : FaiPillTone.neutral,
|
|
monospace: true,
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 6),
|
|
if (isBytes)
|
|
Row(
|
|
children: [
|
|
OutlinedButton.icon(
|
|
onPressed: onPick,
|
|
icon: const Icon(Icons.attach_file, size: 14),
|
|
label: Text(
|
|
pickedFile == null
|
|
? l.flowsTypeBytesPick
|
|
: l.flowsTypeBytesChange,
|
|
),
|
|
),
|
|
const SizedBox(width: FaiSpace.md),
|
|
Expanded(
|
|
child: Text(
|
|
pickedFile == null
|
|
? l.flowsTypeBytesNoFile
|
|
: '${pickedFile!.name} · '
|
|
'${l.flowsTypeBytesSize(pickedFile!.bytes.length)}',
|
|
style: theme.textTheme.bodySmall?.copyWith(
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
],
|
|
)
|
|
else
|
|
TextField(
|
|
controller: textController,
|
|
decoration: const InputDecoration(
|
|
border: OutlineInputBorder(),
|
|
isDense: true,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class _FlowRunDialog extends StatefulWidget {
|
|
final SavedFlow flow;
|
|
final Map<String, String> textInputs;
|
|
final Map<String, Uint8List> fileInputs;
|
|
|
|
const _FlowRunDialog({
|
|
required this.flow,
|
|
required this.textInputs,
|
|
required this.fileInputs,
|
|
});
|
|
|
|
@override
|
|
State<_FlowRunDialog> createState() => _FlowRunDialogState();
|
|
}
|
|
|
|
class _FlowRunDialogState extends State<_FlowRunDialog> {
|
|
late final Future<Map<String, String>> _future;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_future = HubService.instance.runSavedFlow(
|
|
name: widget.flow.name,
|
|
textInputs: widget.textInputs,
|
|
fileInputs: widget.fileInputs,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final l = AppLocalizations.of(context)!;
|
|
return AlertDialog(
|
|
title: Text(l.flowsRunningTitle(widget.flow.name)),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(FaiRadius.md),
|
|
),
|
|
content: ConstrainedBox(
|
|
constraints: const BoxConstraints(maxWidth: 560, maxHeight: 480),
|
|
child: FutureBuilder<Map<String, String>>(
|
|
future: _future,
|
|
builder: (context, snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const SizedBox(height: FaiSpace.md),
|
|
const CircularProgressIndicator(),
|
|
const SizedBox(height: FaiSpace.md),
|
|
Text(
|
|
l.flowsRunning,
|
|
style: theme.textTheme.bodySmall?.copyWith(
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
if (snapshot.hasError) {
|
|
return SingleChildScrollView(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Icon(
|
|
Icons.error_outline,
|
|
color: theme.colorScheme.error,
|
|
size: 20,
|
|
),
|
|
const SizedBox(width: FaiSpace.sm),
|
|
Text(
|
|
l.flowsRunErrorTitle,
|
|
style: theme.textTheme.titleSmall?.copyWith(
|
|
color: theme.colorScheme.error,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: FaiSpace.md),
|
|
FaiErrorBox(
|
|
text: snapshot.error.toString(),
|
|
isError: true,
|
|
maxHeight: 280,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
final outputs = snapshot.data ?? const {};
|
|
if (outputs.isEmpty) {
|
|
return Text(
|
|
l.flowsNoOutputs,
|
|
style: theme.textTheme.bodyMedium,
|
|
);
|
|
}
|
|
return SingleChildScrollView(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
for (final entry in outputs.entries) ...[
|
|
Padding(
|
|
padding: const EdgeInsets.only(bottom: 4),
|
|
child: Text(
|
|
entry.key.toUpperCase(),
|
|
style: theme.textTheme.labelSmall?.copyWith(
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
letterSpacing: 0.6,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(FaiSpace.md),
|
|
decoration: BoxDecoration(
|
|
color: theme.colorScheme.surfaceContainerHigh,
|
|
borderRadius: BorderRadius.circular(FaiRadius.sm),
|
|
border: Border.all(
|
|
color: theme.colorScheme.outlineVariant,
|
|
),
|
|
),
|
|
child: SelectableText(
|
|
entry.value,
|
|
style: FaiTheme.mono(size: 11),
|
|
),
|
|
),
|
|
const SizedBox(height: FaiSpace.md),
|
|
],
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: Text(l.buttonClose),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|