feat(app): run detail's pipeline name opens that pipeline; Retry moves into the more menu

This commit is contained in:
2026-10-23 16:27:20 +01:00
parent 27203fb715
commit 9d61ce1406
13 changed files with 286 additions and 105 deletions
@@ -7,6 +7,7 @@ import 'run_changes_action.dart';
import 'run_detail_content.dart';
import 'run_detail_tabs.dart';
import 'run_more_menu.dart';
import 'run_pipeline_link.dart';
/// The runs detail with standard Cupertino controls. It has no Material
/// ancestor: the host header keeps native navigation, actions and notices, and
@@ -16,7 +17,8 @@ Widget buildCupertinoRunDetail({
required BuildContext context,
required JsonMap run,
required Widget headerActions,
Widget? statusAction,
ValueChanged<num>? onRunOpened,
OpenPipeline? onOpenPipeline,
required bool detailLoading,
required String? error,
required bool copying,
@@ -71,6 +73,7 @@ Widget buildCupertinoRunDetail({
gateway: gateway,
onRunChanged: onRunChanged,
cupertino: true,
onRunOpened: onRunOpened,
),
],
),
@@ -89,7 +92,6 @@ Widget buildCupertinoRunDetail({
state: runStateOf(run['status']),
label: runStatusLabel(run),
),
?statusAction,
],
),
const SizedBox(height: 4),
@@ -98,7 +100,17 @@ Widget buildCupertinoRunDetail({
style: theme.textTheme.navLargeTitleTextStyle,
),
const SizedBox(height: 4),
Text('Run ${run['id']} · Pipeline ${detailPipeline(run)}'),
Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Text('Run ${run['id']} · Pipeline '),
RunPipelineLink(
run: run,
cupertino: true,
onOpenPipeline: onOpenPipeline,
),
],
),
],
),
),
@@ -7,6 +7,7 @@ import 'run_changes_action.dart';
import 'run_detail_content.dart';
import 'run_detail_tabs.dart';
import 'run_more_menu.dart';
import 'run_pipeline_link.dart';
/// The runs detail with standard Material controls.
///
@@ -16,7 +17,8 @@ Widget buildMaterialRunDetail({
required BuildContext context,
required JsonMap run,
required Widget headerActions,
Widget? statusAction,
ValueChanged<num>? onRunOpened,
OpenPipeline? onOpenPipeline,
required bool detailLoading,
required String? error,
required bool copying,
@@ -69,6 +71,7 @@ Widget buildMaterialRunDetail({
gateway: gateway,
onRunChanged: onRunChanged,
cupertino: false,
onRunOpened: onRunOpened,
),
],
),
@@ -86,7 +89,6 @@ Widget buildMaterialRunDetail({
state: runStateOf(run['status']),
label: runStatusLabel(run),
),
?statusAction,
],
),
),
@@ -103,7 +105,17 @@ Widget buildMaterialRunDetail({
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Text('Run ${run['id']}'),
Text('Pipeline ${detailPipeline(run)}'),
Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
const Text('Pipeline '),
RunPipelineLink(
run: run,
cupertino: false,
onOpenPipeline: onOpenPipeline,
),
],
),
headerActions,
],
),
+9 -13
View File
@@ -5,9 +5,8 @@ import 'package:flutter/services.dart';
import '../../../core/api_gateway.dart';
import '../../../core/transport/pipelines_client.dart';
import '../../../ui/adaptive/host.dart';
import '../actions/retry_action.dart';
import '../actions/retry_eligibility.dart';
import 'run_detail_actions.dart';
import 'run_pipeline_link.dart';
import 'run_detail_content.dart';
import 'run_detail_cupertino.dart';
import 'run_detail_material.dart';
@@ -20,6 +19,7 @@ class RunDetailView extends StatefulWidget {
required this.gateway,
required this.onBack,
this.onRunOpened,
this.onOpenPipeline,
this.initialStageKey,
this.initialVisit,
});
@@ -34,6 +34,9 @@ class RunDetailView extends StatefulWidget {
/// the server-identified new run. Null keeps the detail on the retried run.
final ValueChanged<num>? onRunOpened;
/// Opens the run's pipeline from its name in the header.
final OpenPipeline? onOpenPipeline;
/// The route's stage and visit, forwarded to the tab body so a `/runs/:id/
/// stage/:key[?visit=N]` deep link opens that recorded visit. Null is the
/// plain detail.
@@ -64,21 +67,13 @@ class _RunDetailViewState extends State<RunDetailView> {
onRunOpened: widget.onRunOpened,
retry: false,
);
// Retry sits next to the status it answers, and only for a failed run.
final statusAction = retryRunId(run) != null && canRetryRun(run)
? RetryRunAction(
run: run,
gateway: widget.gateway,
onRunChanged: widget.controller.acceptRunDetail,
onRunOpened: widget.onRunOpened,
)
: null;
return cupertino
? buildCupertinoRunDetail(
context: context,
run: run,
headerActions: headerActions,
statusAction: statusAction,
onRunOpened: widget.onRunOpened,
onOpenPipeline: widget.onOpenPipeline,
detailLoading: widget.controller.detailLoading,
error: widget.controller.error,
copying: _copying,
@@ -95,7 +90,8 @@ class _RunDetailViewState extends State<RunDetailView> {
context: context,
run: run,
headerActions: headerActions,
statusAction: statusAction,
onRunOpened: widget.onRunOpened,
onOpenPipeline: widget.onOpenPipeline,
detailLoading: widget.controller.detailLoading,
error: widget.controller.error,
copying: _copying,
+33 -5
View File
@@ -3,6 +3,9 @@ import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../schedules/ui/run/schedule_run_action.dart';
import '../actions/retry_action.dart';
import '../actions/retry_eligibility.dart';
import '../actions/retry_wording.dart';
import '../actions/title_action.dart';
import '../actions/title_wording.dart';
@@ -10,12 +13,21 @@ const runMoreMenuKey = ValueKey<String>('run-more-menu');
/// Whether the run has anything for its more menu.
bool showRunMoreMenu(JsonMap run) =>
runTitleId(run) != null || canScheduleRun(run);
runTitleId(run) != null || canScheduleRun(run) || _canRetry(run);
enum _RunMoreItem { rename, schedule }
bool _canRetry(JsonMap run) => retryRunId(run) != null && canRetryRun(run);
/// The run detail's more menu: Rename and Schedule this run, which act on the
/// run's pipeline record rather than its progress, kept out of the header.
enum _RunMoreItem { retry, rename, schedule }
/// Each item keeps the key its standalone button had.
Key _keyOf(_RunMoreItem item) => switch (item) {
_RunMoreItem.retry => retryActionKey,
_RunMoreItem.rename => runTitleActionKey,
_RunMoreItem.schedule => scheduleRunActionKey,
};
/// The run detail's more menu: Retry (failed runs only), Rename and Schedule
/// this run, kept out of the header.
/// This widget stays mounted while a picked flow runs, so the flow's result
/// still reaches the current run.
class RunMoreMenu extends StatefulWidget {
@@ -25,6 +37,7 @@ class RunMoreMenu extends StatefulWidget {
required this.gateway,
required this.onRunChanged,
required this.cupertino,
this.onRunOpened,
});
final JsonMap run;
@@ -32,6 +45,9 @@ class RunMoreMenu extends StatefulWidget {
final ValueChanged<JsonMap> onRunChanged;
final bool cupertino;
/// Opens the new run an accepted retry names.
final ValueChanged<num>? onRunOpened;
@override
State<RunMoreMenu> createState() => _RunMoreMenuState();
}
@@ -40,12 +56,23 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
JsonMap get run => widget.run;
List<(_RunMoreItem, String)> get _items => [
// Retry is offered only for a failed run that is no longer executing.
if (_canRetry(run)) (_RunMoreItem.retry, retryActionLabel),
if (runTitleId(run) != null) (_RunMoreItem.rename, runTitleActionLabel),
if (canScheduleRun(run)) (_RunMoreItem.schedule, scheduleRunActionLabel),
];
void _pick(BuildContext context, _RunMoreItem item) {
switch (item) {
case _RunMoreItem.retry:
openRetryRunPrompt(
context,
run: run,
gateway: widget.gateway,
onRunChanged: widget.onRunChanged,
onRunOpened: widget.onRunOpened,
owns: (owned) => mounted && retryRunId(widget.run) == owned,
);
case _RunMoreItem.rename:
openRunTitleEditor(
context,
@@ -72,7 +99,7 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
onSelected: (item) => _pick(context, item),
itemBuilder: (_) => [
for (final (item, label) in items)
PopupMenuItem(value: item, child: Text(label)),
PopupMenuItem(key: _keyOf(item), value: item, child: Text(label)),
],
);
}
@@ -91,6 +118,7 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
actions: [
for (final (item, label) in items)
CupertinoActionSheetAction(
key: _keyOf(item),
onPressed: () => Navigator.of(sheet).pop(item),
child: Text(label),
),
@@ -0,0 +1,66 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import 'run_detail_content.dart';
/// Opens a pipeline at a version; 0 means its latest.
typedef OpenPipeline = void Function(int pipelineId, int version);
const runPipelineLinkKey = ValueKey<String>('run-pipeline-link');
/// The run's pipeline id, or null when the server recorded none.
int? runPipelineId(JsonMap run) {
final id = run['pipeline_id'];
return id is num && id > 0 && id == id.truncate() ? id.toInt() : null;
}
/// The run's pipeline name, a link to that pipeline at the run's pinned
/// version when the run names one and the host can navigate.
class RunPipelineLink extends StatelessWidget {
const RunPipelineLink({
super.key,
required this.run,
required this.cupertino,
this.onOpenPipeline,
});
final JsonMap run;
final bool cupertino;
final OpenPipeline? onOpenPipeline;
@override
Widget build(BuildContext context) {
final name = detailPipeline(run);
final id = runPipelineId(run);
final open = onOpenPipeline;
if (id == null || open == null) return Text(name);
final version = run['version'];
void go() => open(id, version is num ? version.toInt() : 0);
final label = Text(
name,
style: const TextStyle(decoration: TextDecoration.underline),
);
return Semantics(
link: true,
label: 'Open pipeline $name',
excludeSemantics: true,
child: cupertino
? CupertinoButton(
key: runPipelineLinkKey,
padding: EdgeInsets.zero,
minimumSize: Size.zero,
onPressed: go,
child: label,
)
: InkWell(
key: runPipelineLinkKey,
onTap: go,
child: DefaultTextStyle.merge(
style: TextStyle(color: Theme.of(context).colorScheme.primary),
child: label,
),
),
);
}
}