wip(app): runs-pipeline-url (retained from the cancelled overrun lane)
This commit is contained in:
@@ -289,6 +289,8 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
server: widget.server,
|
||||
refreshToken: _pipelinesRefresh,
|
||||
onRunStarted: _runStarted,
|
||||
onViewPipelineRuns: (id) =>
|
||||
_delegate.goTo(AppRoute.runsForPipeline(id)),
|
||||
initialPipelineId: route.pipelineId,
|
||||
initialVersion: route.version,
|
||||
initialStageKey: route.stageKey,
|
||||
@@ -302,13 +304,19 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
session: _session,
|
||||
server: widget.server,
|
||||
initialRunId: route.runId,
|
||||
initialPipelineId: route.pipelineId,
|
||||
initialStageKey: route.stageKey,
|
||||
initialVisit: route.visit,
|
||||
initialDecide: route.decide,
|
||||
listRefreshToken: _runsRefresh,
|
||||
notifications: _notifications,
|
||||
onRunSelected: (id) => _delegate.goTo(AppRoute.run(id)),
|
||||
onBack: () => _delegate.goTo(AppRoute.runs),
|
||||
onBack: (id) => _delegate.goTo(
|
||||
id == null ? AppRoute.runs : AppRoute.runsForPipeline(id),
|
||||
),
|
||||
onPipelineFilterChanged: (id) => _delegate.goTo(
|
||||
id == null ? AppRoute.runs : AppRoute.runsForPipeline(id),
|
||||
),
|
||||
),
|
||||
),
|
||||
AppDestination.chat: (_) => ChatDestination(
|
||||
|
||||
@@ -19,6 +19,7 @@ class PipelinesDestination extends StatelessWidget {
|
||||
required this.server,
|
||||
this.refreshToken = 0,
|
||||
this.onRunStarted,
|
||||
this.onViewPipelineRuns,
|
||||
this.initialPipelineId,
|
||||
this.initialVersion = 0,
|
||||
this.initialStageKey,
|
||||
@@ -34,6 +35,7 @@ class PipelinesDestination extends StatelessWidget {
|
||||
|
||||
/// Receives the run id an accepted launch named; the shell opens that route.
|
||||
final ValueChanged<int>? onRunStarted;
|
||||
final ValueChanged<int>? onViewPipelineRuns;
|
||||
|
||||
/// The pipeline and pinned version a deep link names.
|
||||
final int? initialPipelineId;
|
||||
@@ -77,6 +79,7 @@ class PipelinesDestination extends StatelessWidget {
|
||||
gateway: session.gateway,
|
||||
embedded: true,
|
||||
onRunStarted: onRunStarted,
|
||||
onViewPipelineRuns: onViewPipelineRuns,
|
||||
initialPipelineId: initialPipelineId,
|
||||
initialVersion: initialVersion,
|
||||
initialStageKey: initialStageKey,
|
||||
|
||||
@@ -19,11 +19,13 @@ class RunsDestination extends StatelessWidget {
|
||||
required this.session,
|
||||
required this.server,
|
||||
this.initialRunId,
|
||||
this.initialPipelineId,
|
||||
this.initialStageKey,
|
||||
this.initialVisit,
|
||||
this.initialDecide = false,
|
||||
this.onRunSelected,
|
||||
this.onBack,
|
||||
this.onPipelineFilterChanged,
|
||||
this.listRefreshToken = 0,
|
||||
this.notifications,
|
||||
});
|
||||
@@ -31,6 +33,7 @@ class RunsDestination extends StatelessWidget {
|
||||
final AppSession session;
|
||||
final ServerEndpoint server;
|
||||
final int? initialRunId;
|
||||
final int? initialPipelineId;
|
||||
|
||||
/// The stage key and optional visit a `/runs/:id/stage/:key[?visit=N]` route
|
||||
/// names. They reach the detail only through [RunsScreen]; the destination
|
||||
@@ -43,7 +46,8 @@ class RunsDestination extends StatelessWidget {
|
||||
final bool initialDecide;
|
||||
|
||||
final ValueChanged<int>? onRunSelected;
|
||||
final VoidCallback? onBack;
|
||||
final ValueChanged<int?>? onBack;
|
||||
final ValueChanged<int?>? onPipelineFilterChanged;
|
||||
|
||||
/// Advances when a launch was accepted elsewhere. The mounted Runs screen
|
||||
/// re-reads its list once; no row is inserted locally.
|
||||
@@ -87,6 +91,7 @@ class RunsDestination extends StatelessWidget {
|
||||
Widget _runsScreen() => RunsScreen(
|
||||
gateway: session.gateway,
|
||||
initialRunId: initialRunId,
|
||||
initialPipelineId: initialPipelineId,
|
||||
initialStageKey: initialStageKey,
|
||||
initialVisit: initialVisit,
|
||||
initialDecide: initialDecide,
|
||||
@@ -95,5 +100,6 @@ class RunsDestination extends StatelessWidget {
|
||||
notifications: notifications,
|
||||
onRunSelected: onRunSelected,
|
||||
onBack: onBack,
|
||||
onPipelineFilterChanged: onPipelineFilterChanged,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ class PipelinesScreen extends StatefulWidget {
|
||||
this.embedded = false,
|
||||
this.syncToken = 0,
|
||||
this.onRunStarted,
|
||||
this.onViewPipelineRuns,
|
||||
this.initialPipelineId,
|
||||
this.initialVersion = 0,
|
||||
this.initialStageKey,
|
||||
@@ -45,6 +46,7 @@ class PipelinesScreen extends StatefulWidget {
|
||||
/// Receives the run id an accepted launch names, so the composition can open
|
||||
/// the existing run route. The feature never navigates on its own.
|
||||
final ValueChanged<int>? onRunStarted;
|
||||
final ValueChanged<int>? onViewPipelineRuns;
|
||||
|
||||
/// The pipeline a deep link names, opened after the list read starts.
|
||||
final int? initialPipelineId;
|
||||
@@ -170,6 +172,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
gateway: widget.gateway,
|
||||
showBack: true,
|
||||
onRunStarted: widget.onRunStarted,
|
||||
onViewPipelineRuns: widget.onViewPipelineRuns,
|
||||
stageKey: stageKey,
|
||||
stagePipelineId: widget.initialPipelineId,
|
||||
stageVersion: widget.initialVersion,
|
||||
@@ -192,6 +195,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
gateway: widget.gateway,
|
||||
showBack: false,
|
||||
onRunStarted: widget.onRunStarted,
|
||||
onViewPipelineRuns: widget.onViewPipelineRuns,
|
||||
stageKey: stageKey,
|
||||
stagePipelineId: widget.initialPipelineId,
|
||||
stageVersion: widget.initialVersion,
|
||||
|
||||
@@ -30,6 +30,7 @@ class PipelineDetailPanel extends StatefulWidget {
|
||||
required this.gateway,
|
||||
required this.showBack,
|
||||
this.onRunStarted,
|
||||
this.onViewPipelineRuns,
|
||||
this.stageKey,
|
||||
this.stagePipelineId,
|
||||
this.stageVersion = 0,
|
||||
@@ -45,6 +46,7 @@ class PipelineDetailPanel extends StatefulWidget {
|
||||
|
||||
/// A run started from this detail's Run action; receives the server's id.
|
||||
final ValueChanged<int>? onRunStarted;
|
||||
final ValueChanged<int>? onViewPipelineRuns;
|
||||
|
||||
/// The stage the route names for this detail, or null when it names none.
|
||||
final String? stageKey;
|
||||
@@ -337,6 +339,25 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
|
||||
onRunStarted: widget.onRunStarted,
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Semantics(
|
||||
button: true,
|
||||
label: detail.name.trim().isEmpty
|
||||
? 'View runs of this pipeline'
|
||||
: 'View runs of ${detail.name}',
|
||||
child: ExcludeSemantics(
|
||||
child: TextButton.icon(
|
||||
onPressed: widget.onViewPipelineRuns == null
|
||||
? null
|
||||
: () => widget.onViewPipelineRuns!(detail.id),
|
||||
icon: const Icon(Icons.list_alt),
|
||||
label: const Text('Runs'),
|
||||
key: const Key('pipeline-view-runs'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -24,6 +24,7 @@ class RunsScreen extends StatefulWidget {
|
||||
super.key,
|
||||
required this.gateway,
|
||||
this.initialRunId,
|
||||
this.initialPipelineId,
|
||||
this.initialStageKey,
|
||||
this.initialVisit,
|
||||
this.initialDecide = false,
|
||||
@@ -31,6 +32,7 @@ class RunsScreen extends StatefulWidget {
|
||||
this.listRefreshToken = 0,
|
||||
this.onRunSelected,
|
||||
this.onBack,
|
||||
this.onPipelineFilterChanged,
|
||||
this.attentionStore = const SharedPreferencesAttentionStore(),
|
||||
this.attentionNow,
|
||||
this.notifications,
|
||||
@@ -40,6 +42,7 @@ class RunsScreen extends StatefulWidget {
|
||||
|
||||
/// The run the current route names, or null for the list.
|
||||
final int? initialRunId;
|
||||
final int? initialPipelineId;
|
||||
|
||||
/// The recorded stage visit the route names inside [initialRunId]. The detail
|
||||
/// applies it once per route target; the feature never invents a visit.
|
||||
@@ -60,7 +63,8 @@ class RunsScreen extends StatefulWidget {
|
||||
final int listRefreshToken;
|
||||
|
||||
final ValueChanged<int>? onRunSelected;
|
||||
final VoidCallback? onBack;
|
||||
final ValueChanged<int?>? onBack;
|
||||
final ValueChanged<int?>? onPipelineFilterChanged;
|
||||
|
||||
/// Persisted attention dismissals and the clock for its local-day window.
|
||||
/// The app uses SharedPreferences; tests and fixtures inject a memory store.
|
||||
@@ -77,6 +81,8 @@ class RunsScreen extends StatefulWidget {
|
||||
class _RunsScreenState extends State<RunsScreen> {
|
||||
late final RunsController controller;
|
||||
num? _shownRunId;
|
||||
int? _reportedPipelineId;
|
||||
bool _applyingRoutePipeline = false;
|
||||
|
||||
/// The route's decision request is one-shot: the first loaded detail for the
|
||||
/// named run consumes it, whether or not that run is waiting.
|
||||
@@ -86,8 +92,14 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
controller = RunsController(RunsRepository(widget.gateway));
|
||||
_reportedPipelineId = widget.initialPipelineId;
|
||||
if (widget.initialPipelineId != null) {
|
||||
controller.clearFilters();
|
||||
controller.setPipeline(widget.initialPipelineId);
|
||||
}
|
||||
controller.listen(widget.gateway.frames);
|
||||
controller.addListener(_selectionChanged);
|
||||
controller.addListener(_pipelineFilterChanged);
|
||||
controller.addListener(_detailChanged);
|
||||
controller.load(widget.initialRunId);
|
||||
}
|
||||
@@ -99,6 +111,21 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
widget.initialDecide != oldWidget.initialDecide) {
|
||||
_decideConsumed = false;
|
||||
}
|
||||
if (widget.initialPipelineId != oldWidget.initialPipelineId) {
|
||||
final id = widget.initialPipelineId;
|
||||
// A run detail replaces the list URL but retains its active list filter.
|
||||
// Only a route back to the list can explicitly clear that facet.
|
||||
if (id != null || widget.initialRunId == null) {
|
||||
_applyingRoutePipeline = true;
|
||||
try {
|
||||
if (id != null) controller.clearFilters();
|
||||
controller.setPipeline(id);
|
||||
_reportedPipelineId = id;
|
||||
} finally {
|
||||
_applyingRoutePipeline = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (widget.syncToken != oldWidget.syncToken) {
|
||||
controller.resync();
|
||||
}
|
||||
@@ -132,6 +159,19 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
|
||||
void _pipelineFilterChanged() {
|
||||
final id = controller.pipelineId;
|
||||
if (_applyingRoutePipeline) {
|
||||
_reportedPipelineId = id;
|
||||
return;
|
||||
}
|
||||
if (id == _reportedPipelineId) return;
|
||||
_reportedPipelineId = id;
|
||||
if (controller.selectedRunId == null) {
|
||||
widget.onPipelineFilterChanged?.call(id);
|
||||
}
|
||||
}
|
||||
|
||||
/// Opens the route's decision prompt after the named detail has arrived.
|
||||
/// A non-waiting run consumes the request without a prompt, and the prompt
|
||||
/// itself only closes; the detail underneath is left as it is.
|
||||
@@ -166,12 +206,13 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
|
||||
void _back() {
|
||||
controller.back();
|
||||
widget.onBack?.call();
|
||||
widget.onBack?.call(controller.pipelineId);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.removeListener(_selectionChanged);
|
||||
controller.removeListener(_pipelineFilterChanged);
|
||||
controller.removeListener(_detailChanged);
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
|
||||
@@ -37,6 +37,23 @@ class RunsFilters extends StatelessWidget {
|
||||
Widget _materialToolbar(int count) => Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
PopupMenuButton<_FilterChoice>(
|
||||
tooltip: 'Filter by pipeline',
|
||||
onSelected: _apply,
|
||||
itemBuilder: (context) => [
|
||||
const PopupMenuItem(
|
||||
value: (kind: 'pipeline', value: ''),
|
||||
child: Text('Any pipeline'),
|
||||
),
|
||||
for (final pipeline in _pipelines)
|
||||
CheckedPopupMenuItem(
|
||||
value: (kind: 'pipeline', value: '${pipeline.$1}'),
|
||||
checked: controller.pipelineId == pipeline.$1,
|
||||
child: Text(pipeline.$2),
|
||||
),
|
||||
],
|
||||
child: _materialButton(Icons.account_tree_outlined, 'Pipeline'),
|
||||
),
|
||||
PopupMenuButton<_FilterChoice>(
|
||||
tooltip: count > 0
|
||||
? '$count active ${count == 1 ? 'filter' : 'filters'}'
|
||||
@@ -102,6 +119,12 @@ class RunsFilters extends StatelessWidget {
|
||||
];
|
||||
|
||||
void _apply(_FilterChoice choice) {
|
||||
if (choice.kind == 'pipeline') {
|
||||
controller.setPipeline(
|
||||
choice.value.isEmpty ? null : int.parse(choice.value),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (choice.kind == 'status') {
|
||||
controller.setStatus(choice.value);
|
||||
} else if (choice.kind == 'schedule') {
|
||||
@@ -111,6 +134,19 @@ class RunsFilters extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
List<(int, String)> get _pipelines {
|
||||
final names = <int, String>{};
|
||||
for (final run in controller.runs) {
|
||||
final rawId = run['pipeline_id'];
|
||||
final id = rawId is num ? rawId.toInt() : int.tryParse('$rawId');
|
||||
if (id == null || id <= 0) continue;
|
||||
final name = '${run['name'] ?? ''}'.trim();
|
||||
names.putIfAbsent(id, () => name.isEmpty ? 'Pipeline $id' : name);
|
||||
}
|
||||
return names.entries.map((entry) => (entry.key, entry.value)).toList()
|
||||
..sort((a, b) => a.$2.toLowerCase().compareTo(b.$2.toLowerCase()));
|
||||
}
|
||||
|
||||
Widget _cupertinoToolbar(BuildContext context, int count) => Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -148,6 +184,17 @@ class RunsFilters extends StatelessWidget {
|
||||
builder: (context, _) => CupertinoActionSheet(
|
||||
title: const Text('Filter runs'),
|
||||
actions: [
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () => controller.setPipeline(null),
|
||||
child: const Text('Any pipeline'),
|
||||
),
|
||||
for (final pipeline in _pipelines)
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () => controller.setPipeline(pipeline.$1),
|
||||
child: Text(
|
||||
'${controller.pipelineId == pipeline.$1 ? '✓ ' : ''}${pipeline.$2}',
|
||||
),
|
||||
),
|
||||
for (final status in runStates)
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () => controller.setStatus(status),
|
||||
|
||||
@@ -21,7 +21,7 @@ Widget materialApp(
|
||||
ServerEndpoint server, {
|
||||
int? initialRunId,
|
||||
ValueChanged<int>? onRunSelected,
|
||||
VoidCallback? onBack,
|
||||
ValueChanged<int?>? onBack,
|
||||
}) => MaterialApp(
|
||||
home: Scaffold(
|
||||
body: RunsDestination(
|
||||
|
||||
@@ -86,6 +86,30 @@ void main() {
|
||||
expect(find.text('Viewing v1 (latest v2).'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('detail Runs action names and opens that pipeline filter', (
|
||||
tester,
|
||||
) async {
|
||||
final fixture = PipelineFixture();
|
||||
final gateway = gatewayFor(fixture);
|
||||
final opened = <int>[];
|
||||
tester.view.physicalSize = const Size(1100, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: PipelinesScreen(gateway: gateway, onViewPipelineRuns: opened.add),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.bySemanticsLabel('View runs of Alpha review'), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('pipeline-view-runs')));
|
||||
expect(opened, [1]);
|
||||
});
|
||||
|
||||
testWidgets('refresh keeps the selected row and its detail', (tester) async {
|
||||
final fixture = PipelineFixture();
|
||||
final gateway = gatewayFor(fixture);
|
||||
|
||||
@@ -46,17 +46,21 @@ const _runs = [
|
||||
Widget _materialScreen(
|
||||
_Gateway gateway, {
|
||||
int? initialRunId,
|
||||
int? initialPipelineId,
|
||||
int syncToken = 0,
|
||||
ValueChanged<int>? onRunSelected,
|
||||
VoidCallback? onBack,
|
||||
ValueChanged<int?>? onBack,
|
||||
ValueChanged<int?>? onPipelineFilterChanged,
|
||||
}) => MaterialApp(
|
||||
home: Scaffold(
|
||||
body: RunsScreen(
|
||||
gateway: gateway,
|
||||
initialRunId: initialRunId,
|
||||
initialPipelineId: initialPipelineId,
|
||||
syncToken: syncToken,
|
||||
onRunSelected: onRunSelected,
|
||||
onBack: onBack,
|
||||
onPipelineFilterChanged: onPipelineFilterChanged,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -149,12 +153,12 @@ void main() {
|
||||
tester,
|
||||
) async {
|
||||
int? selected;
|
||||
var backs = 0;
|
||||
int? backedPipeline;
|
||||
await tester.pumpWidget(
|
||||
_materialScreen(
|
||||
gateway,
|
||||
onRunSelected: (id) => selected = id,
|
||||
onBack: () => backs++,
|
||||
onBack: (id) => backedPipeline = id,
|
||||
),
|
||||
);
|
||||
await _mountList(tester, gateway);
|
||||
@@ -167,10 +171,60 @@ void main() {
|
||||
|
||||
await tester.tap(find.text('Back to list'));
|
||||
await tester.pump();
|
||||
expect(backs, 1);
|
||||
expect(backedPipeline, isNull);
|
||||
expect(find.text('Alpha run'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'pipeline route shows its chip and clearing reports the URL change',
|
||||
(tester) async {
|
||||
int? changedPipeline = 3;
|
||||
await tester.pumpWidget(
|
||||
_materialScreen(
|
||||
gateway,
|
||||
initialPipelineId: 3,
|
||||
onPipelineFilterChanged: (id) => changedPipeline = id,
|
||||
),
|
||||
);
|
||||
await _mountList(tester, gateway);
|
||||
|
||||
expect(find.text('Pipeline 3'), findsOneWidget);
|
||||
expect(changedPipeline, 3);
|
||||
await tester.tap(find.byTooltip('Clear filter: Pipeline 3'));
|
||||
await tester.pump();
|
||||
expect(changedPipeline, isNull);
|
||||
expect(find.text('Pipeline 3'), findsNothing);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('run detail keeps the pipeline filter for Back routing', (
|
||||
tester,
|
||||
) async {
|
||||
int? backPipeline;
|
||||
await tester.pumpWidget(
|
||||
_materialScreen(
|
||||
gateway,
|
||||
initialPipelineId: 3,
|
||||
onBack: (id) => backPipeline = id,
|
||||
),
|
||||
);
|
||||
await _mountList(tester, gateway);
|
||||
await tester.pumpWidget(
|
||||
_materialScreen(
|
||||
gateway,
|
||||
initialRunId: 2,
|
||||
onBack: (id) => backPipeline = id,
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
gateway.replyDetail(2, 0, {'id': 2, 'title': 'Beta run'});
|
||||
await tester.pump();
|
||||
|
||||
await tester.tap(find.text('Back to list'));
|
||||
await tester.pump();
|
||||
expect(backPipeline, 3);
|
||||
});
|
||||
|
||||
testWidgets('a route change opens and closes the named run', (tester) async {
|
||||
await tester.pumpWidget(_materialScreen(gateway, initialRunId: 2));
|
||||
await _mountList(tester, gateway);
|
||||
|
||||
Reference in New Issue
Block a user