Files
pipelines/app/tool/graph_zoom_probe.dart
T

171 lines
4.5 KiB
Dart

// Isolated browser fixture for the graph viewport (pan/zoom/expanded).
//
// Build and probe (from app/):
// flutter build web -t tool/graph_zoom_probe.dart \
// --output build/probe-graph-zoom
// PROBE_VARIANT=material OPENCODE_ARTIFACT_DIR=DIR node tool/graph_zoom_probe.mjs
//
// Server-shaped fixtures only; no server, run or operator session is touched.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/graph/widgets/definition_graph_view.dart';
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
const String _longKey = 'implementer-with-an-unusually-long-stage-label';
JsonMap _definition() => <String, dynamic>{
'name': 'Viewport probe',
'stages': <dynamic>[
<String, dynamic>{
'key': 'plan',
'type': 'model',
'edges': <String, String?>{'success': 'build', 'error': '#'},
'fallback_error': true,
},
<String, dynamic>{
'key': 'build',
'type': 'model',
'edges': <String, String?>{'success': _longKey, 'retry': 'build'},
},
<String, dynamic>{
'key': _longKey,
'type': 'model',
'edges': <String, String?>{'success': 'audit', 'blocked': '#failure'},
},
<String, dynamic>{
'key': 'audit',
'type': 'model',
'edges': <String, String?>{'success': '#success', 'error': '#failure'},
},
],
};
JsonMap _run() => <String, dynamic>{
'id': 701,
'title': 'Viewport probe',
'status': 'succeeded',
'executing': false,
'graph': _definition(),
'steps': <dynamic>[
<String, dynamic>{
'stage': 'plan',
'sequence': 1,
'status': 'completed',
'outcome': 'success',
'target': 'build',
},
<String, dynamic>{
'stage': 'build',
'sequence': 2,
'status': 'completed',
'outcome': 'success',
'target': _longKey,
},
],
'current_stage': '',
};
void main() {
final parameters = Uri.base.queryParameters;
runApp(
_ProbeApp(
runMode: parameters['view'] == 'run',
cupertino: parameters['style'] == 'cupertino',
scale: double.tryParse(parameters['scale'] ?? '') ?? 1,
),
);
}
class _ProbeApp extends StatelessWidget {
const _ProbeApp({
required this.runMode,
required this.cupertino,
required this.scale,
});
final bool runMode;
final bool cupertino;
final double scale;
@override
Widget build(BuildContext context) {
final page = _ProbePage(runMode: runMode, scale: scale);
if (cupertino) {
return CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.dark),
home: CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text('Graph viewport'),
),
child: SafeArea(child: page),
),
);
}
return MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
darkTheme: ThemeData(
platform: TargetPlatform.android,
brightness: Brightness.dark,
),
themeMode: ThemeMode.system,
home: Scaffold(
appBar: AppBar(title: const Text('Graph viewport')),
body: SafeArea(child: page),
),
);
}
}
class _ProbePage extends StatefulWidget {
const _ProbePage({required this.runMode, required this.scale});
final bool runMode;
final double scale;
@override
State<_ProbePage> createState() => _ProbePageState();
}
class _ProbePageState extends State<_ProbePage> {
String? _selected = 'build';
void _select(String key) => setState(() => _selected = key);
@override
Widget build(BuildContext context) {
final runMode = widget.runMode;
final view = runMode
? RunGraphView(
graph: _definition(),
run: _run(),
selectedStage: _selected,
onStageSelected: _select,
)
: DefinitionGraphView(
graph: _definition(),
selectedStage: _selected,
onSelected: _select,
);
return Padding(
padding: const EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Selected: ${_selected ?? 'none'}'),
const SizedBox(height: 8),
Expanded(
child: MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: TextScaler.linear(widget.scale)),
child: view,
),
),
],
),
);
}
}