feat(app): Retry sits beside a failed run's status

This commit is contained in:
2026-10-23 16:05:15 +01:00
parent ba484f044f
commit e0e3517d0b
5 changed files with 115 additions and 7 deletions
@@ -19,6 +19,7 @@ class RunDetailActions extends StatelessWidget {
required this.gateway, required this.gateway,
required this.onRunChanged, required this.onRunChanged,
this.onRunOpened, this.onRunOpened,
this.retry = true,
}); });
final JsonMap run; final JsonMap run;
@@ -28,6 +29,9 @@ class RunDetailActions extends StatelessWidget {
/// Opens the new run named by an accepted retry reply; see [RetryRunAction]. /// Opens the new run named by an accepted retry reply; see [RetryRunAction].
final ValueChanged<num>? onRunOpened; final ValueChanged<num>? onRunOpened;
/// False when the host draws Retry beside the run's failed status instead.
final bool retry;
@override @override
Widget build(BuildContext context) => Column( Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -51,7 +55,7 @@ class RunDetailActions extends StatelessWidget {
), ),
if (canScheduleRun(run)) if (canScheduleRun(run))
ScheduleRunAction(run: run, gateway: gateway), ScheduleRunAction(run: run, gateway: gateway),
if (retryRunId(run) != null && canRetryRun(run)) if (retry && retryRunId(run) != null && canRetryRun(run))
RetryRunAction( RetryRunAction(
run: run, run: run,
gateway: gateway, gateway: gateway,
@@ -15,6 +15,7 @@ Widget buildCupertinoRunDetail({
required BuildContext context, required BuildContext context,
required JsonMap run, required JsonMap run,
required Widget headerActions, required Widget headerActions,
Widget? statusAction,
required bool detailLoading, required bool detailLoading,
required String? error, required String? error,
required bool copying, required bool copying,
@@ -72,9 +73,17 @@ Widget buildCupertinoRunDetail({
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
RunStatusKicker( Wrap(
state: runStateOf(run['status']), spacing: 8,
label: runStatusLabel(run), runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
RunStatusKicker(
state: runStateOf(run['status']),
label: runStatusLabel(run),
),
?statusAction,
],
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
Text( Text(
@@ -15,6 +15,7 @@ Widget buildMaterialRunDetail({
required BuildContext context, required BuildContext context,
required JsonMap run, required JsonMap run,
required Widget headerActions, required Widget headerActions,
Widget? statusAction,
required bool detailLoading, required bool detailLoading,
required String? error, required String? error,
required bool copying, required bool copying,
@@ -62,9 +63,17 @@ Widget buildMaterialRunDetail({
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0), padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
child: Align( child: Align(
alignment: AlignmentDirectional.centerStart, alignment: AlignmentDirectional.centerStart,
child: RunStatusKicker( child: Wrap(
state: runStateOf(run['status']), spacing: 8,
label: runStatusLabel(run), runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
RunStatusKicker(
state: runStateOf(run['status']),
label: runStatusLabel(run),
),
?statusAction,
],
), ),
), ),
), ),
@@ -5,6 +5,8 @@ import 'package:flutter/services.dart';
import '../../../core/api_gateway.dart'; import '../../../core/api_gateway.dart';
import '../../../core/transport/pipelines_client.dart'; import '../../../core/transport/pipelines_client.dart';
import '../../../ui/adaptive/host.dart'; import '../../../ui/adaptive/host.dart';
import '../actions/retry_action.dart';
import '../actions/retry_eligibility.dart';
import 'run_detail_actions.dart'; import 'run_detail_actions.dart';
import 'run_detail_content.dart'; import 'run_detail_content.dart';
import 'run_detail_cupertino.dart'; import 'run_detail_cupertino.dart';
@@ -60,12 +62,23 @@ class _RunDetailViewState extends State<RunDetailView> {
gateway: widget.gateway, gateway: widget.gateway,
onRunChanged: widget.controller.acceptRunDetail, onRunChanged: widget.controller.acceptRunDetail,
onRunOpened: widget.onRunOpened, 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 return cupertino
? buildCupertinoRunDetail( ? buildCupertinoRunDetail(
context: context, context: context,
run: run, run: run,
headerActions: headerActions, headerActions: headerActions,
statusAction: statusAction,
detailLoading: widget.controller.detailLoading, detailLoading: widget.controller.detailLoading,
error: widget.controller.error, error: widget.controller.error,
copying: _copying, copying: _copying,
@@ -82,6 +95,7 @@ class _RunDetailViewState extends State<RunDetailView> {
context: context, context: context,
run: run, run: run,
headerActions: headerActions, headerActions: headerActions,
statusAction: statusAction,
detailLoading: widget.controller.detailLoading, detailLoading: widget.controller.detailLoading,
error: widget.controller.error, error: widget.controller.error,
copying: _copying, copying: _copying,
@@ -0,0 +1,72 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
import 'package:pipelines_app/ui/status/run_status_icon.dart';
class _FakeGateway implements ApiGateway {
_FakeGateway(this.detail);
final JsonMap detail;
@override
Stream<JsonMap> get frames => const Stream<JsonMap>.empty();
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
if (type != 'get_run') throw UnsupportedError(type);
return Future.value({'run_detail': detail});
}
}
Future<void> _pump(WidgetTester tester, String status, bool cupertino) async {
tester.view.physicalSize = const Size(390, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final controller = RunsController(
RunsRepository(
_FakeGateway({
'id': 21,
'title': 'Nightly build',
'name': 'nightly',
'status': status,
'executing': false,
}),
),
);
await controller.select(21);
final view = RunDetailView(
controller: controller,
gateway: _FakeGateway(const {}),
onBack: () {},
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: view))
: MaterialApp(home: Scaffold(body: view)),
);
await tester.pumpAndSettle();
}
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'cupertino' : 'material';
testWidgets('$host: Retry sits beside the failed status', (tester) async {
await _pump(tester, 'failed', cupertino);
final retry = find.text('Retry');
expect(retry, findsOneWidget);
final kicker = tester.getRect(find.byType(RunStatusKicker));
final button = tester.getRect(retry);
expect(button.center.dy, moreOrLessEquals(kicker.center.dy, epsilon: 8));
expect(button.left, greaterThan(kicker.right));
});
testWidgets('$host: a succeeded run offers no Retry', (tester) async {
await _pump(tester, 'succeeded', cupertino);
expect(find.text('Retry'), findsNothing);
});
}
}