wip(app): runs-pipeline-url (retained from the cancelled overrun lane)
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user