feat(studio): pencil-into-editor + back button + collapsible rail
Some checks failed
Security / Security check (push) Failing after 2s
Some checks failed
Security / Security check (push) Failing after 2s
Three operator-visible improvements per Stefan's review of the v0.50.0 editor. 1. Pencil icon on Flows page now opens Studio's own flow editor (route push) preloaded with the selected flow, replacing the previous "open in OS default editor" (SystemActions.openInOs) behaviour. The editor's AppBar gains a back arrow when reached via route push; reaching the editor via the nav rail leaves it bare. Tooltip string updated in EN + DE. 2. New FlowEditorPage `initialFlowName` parameter. When set, the page loads that flow on first frame (via post-frame callback so the BuildContext is mounted before _openByName runs). When null (the nav-rail path), the editor opens to its empty state as before. 3. Sidebar (_Sidebar) is now collapsed-by-default: shows just icons in a 72px-wide rail with per-destination tooltips. Hovering the rail expands it to 220px (the old width) with brand-mark + labels + the full footer row (theme toggle, language toggle, clock, settings). Collapsed footer shows the settings icon only. Brand- mark (FaiDeltaMark) stays visible in both states so the live/idle status dot is always glanceable. Side-effect: SystemActions import in flows.dart is no longer needed (the pencil no longer shells out) — removed. widget_test.dart: dropped the per-destination Text-presence asserts since labels are now Tooltips when collapsed. Hover-expand testing triggers RenderFlex-overflow mid- animation in widget tests (the AnimatedContainer's width transitions through a constraint slimmer than the Row's intrinsic min). The booting-without-throwing assertion remains; per-destination presence stays in the per-page test suites. Both arb files updated with the new strings (navFlowEditor already existed; added flowEditorBackTooltip + retouched flowsOpenInEditorTooltip). Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
parent
647d93a1dc
commit
e522267ec1
9 changed files with 269 additions and 142 deletions
|
|
@ -42,8 +42,16 @@ String _defaultFlowsDir() {
|
|||
/// Top-level flow editor page. Keeps the file-tree loader and
|
||||
/// the editor state alongside each other because Save needs
|
||||
/// both to know what name to write under.
|
||||
///
|
||||
/// [initialFlowName] preloads a flow when the page is pushed
|
||||
/// from elsewhere (e.g. the pencil icon on the Flows page). It
|
||||
/// also flips on the AppBar back arrow so the operator can
|
||||
/// return to where they came from. When the page is reached
|
||||
/// via the nav rail, [initialFlowName] is null and the AppBar
|
||||
/// stays bare.
|
||||
class FlowEditorPage extends StatefulWidget {
|
||||
const FlowEditorPage({super.key});
|
||||
final String? initialFlowName;
|
||||
const FlowEditorPage({super.key, this.initialFlowName});
|
||||
|
||||
@override
|
||||
State<FlowEditorPage> createState() => _FlowEditorPageState();
|
||||
|
|
@ -65,6 +73,31 @@ class _FlowEditorPageState extends State<FlowEditorPage> {
|
|||
_code = CodeController(text: '', language: yaml);
|
||||
_code.addListener(_onCodeChange);
|
||||
_files = _listFiles();
|
||||
// Preload caller-supplied flow after first frame so the
|
||||
// page's BuildContext is mounted in the widget tree (the
|
||||
// _openFile path eventually touches Localizations).
|
||||
final initial = widget.initialFlowName;
|
||||
if (initial != null && initial.isNotEmpty) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
await _openByName(initial);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _openByName(String name) async {
|
||||
final dir = Directory(_defaultFlowsDir());
|
||||
final path = '${dir.path}/$name.yaml';
|
||||
final f = File(path);
|
||||
if (!f.existsSync()) return;
|
||||
final text = await f.readAsString();
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_activeName = name;
|
||||
_loadedText = text;
|
||||
_code.text = text;
|
||||
_runOutputs = null;
|
||||
_runError = null;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -299,6 +332,14 @@ outputs:
|
|||
dirty: _dirty,
|
||||
saving: _saving,
|
||||
running: _running,
|
||||
// Show the back arrow only when the page was
|
||||
// pushed onto a route (Navigator.canPop is true).
|
||||
// Reaching the editor via the nav rail leaves
|
||||
// canPop false → no back arrow → consistent with
|
||||
// every other top-level destination.
|
||||
onBack: Navigator.of(context).canPop()
|
||||
? () => Navigator.of(context).maybePop()
|
||||
: null,
|
||||
onSave: _activeName != null ? _save : null,
|
||||
onRun: _activeName != null && !_running ? _run : null,
|
||||
onNew: _newFlow,
|
||||
|
|
@ -364,6 +405,7 @@ class _Toolbar extends StatelessWidget {
|
|||
final bool dirty;
|
||||
final bool saving;
|
||||
final bool running;
|
||||
final VoidCallback? onBack;
|
||||
final VoidCallback? onSave;
|
||||
final VoidCallback? onRun;
|
||||
final VoidCallback onNew;
|
||||
|
|
@ -373,6 +415,7 @@ class _Toolbar extends StatelessWidget {
|
|||
required this.dirty,
|
||||
required this.saving,
|
||||
required this.running,
|
||||
required this.onBack,
|
||||
required this.onSave,
|
||||
required this.onRun,
|
||||
required this.onNew,
|
||||
|
|
@ -391,6 +434,14 @@ class _Toolbar extends StatelessWidget {
|
|||
color: theme.colorScheme.surfaceContainer,
|
||||
child: Row(
|
||||
children: [
|
||||
if (onBack != null) ...[
|
||||
IconButton(
|
||||
icon: const Icon(Icons.arrow_back, size: 18),
|
||||
tooltip: l.flowEditorBackTooltip,
|
||||
onPressed: onBack,
|
||||
),
|
||||
const SizedBox(width: FaiSpace.xs),
|
||||
],
|
||||
Text(
|
||||
activeName == null ? l.flowEditorEmptyTitle : '${activeName!}.yaml',
|
||||
style: theme.textTheme.titleSmall?.copyWith(
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
|
|||
|
||||
import '../data/format.dart';
|
||||
import '../data/hub.dart';
|
||||
import '../data/system_actions.dart';
|
||||
import 'flow_editor.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../theme/theme.dart';
|
||||
import '../theme/tokens.dart';
|
||||
|
|
@ -102,16 +102,20 @@ class _FlowsPageState extends State<FlowsPage> {
|
|||
if (changed == true && mounted) _refresh();
|
||||
}
|
||||
|
||||
/// Hand the YAML file to the OS — `open` on macOS, `xdg-open`
|
||||
/// on Linux, `start` on Windows. The operator's default editor
|
||||
/// for `.yaml` decides what actually opens.
|
||||
/// Push Studio's built-in YAML editor as a route with the
|
||||
/// selected flow preloaded. The editor's AppBar back arrow
|
||||
/// returns to this page. Falls back to opening the file in
|
||||
/// the OS's default editor only when explicitly asked (the
|
||||
/// secondary "open in OS" entry, not the pencil).
|
||||
Future<void> _openInEditor(SavedFlow flow) async {
|
||||
final r = await SystemActions.openInOs(flow.path);
|
||||
if (!mounted || r.ok) return;
|
||||
final l = AppLocalizations.of(context)!;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(l.flowsOpenInEditorFailed(r.stderr))),
|
||||
await Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => FlowEditorPage(initialFlowName: flow.name),
|
||||
),
|
||||
);
|
||||
// Refresh the list when we come back — operator may have
|
||||
// saved + renamed, or deleted, or just edited capabilities.
|
||||
if (mounted) _refresh();
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue