66 lines
2.2 KiB
Dart
66 lines
2.2 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../actions/cancel_eligibility.dart';
|
|
import '../actions/cancel_run_action.dart';
|
|
import '../actions/retry_action.dart';
|
|
import '../actions/retry_eligibility.dart';
|
|
import 'run_decision_notice.dart';
|
|
|
|
/// Native actions on the loaded run, all using the app's one gateway and
|
|
/// applying only accepted server detail through the same controller callback.
|
|
class RunDetailActions extends StatelessWidget {
|
|
const RunDetailActions({
|
|
super.key,
|
|
required this.run,
|
|
required this.gateway,
|
|
required this.onRunChanged,
|
|
this.onRunOpened,
|
|
this.retry = true,
|
|
});
|
|
|
|
final JsonMap run;
|
|
final ApiGateway gateway;
|
|
final ValueChanged<JsonMap> onRunChanged;
|
|
|
|
/// Opens the new run named by an accepted retry reply; see [RetryRunAction].
|
|
final ValueChanged<num>? onRunOpened;
|
|
|
|
/// False when the host draws Retry beside the run's failed status instead.
|
|
final bool retry;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Every run action uses one native style, as the web's `.run-action`:
|
|
// outlined on Material, tinted on Cupertino; Cancel alone is tinted
|
|
// destructive. Standard native spacing keeps adjacent buttons distinct.
|
|
// Only actions that render are included: a hidden zero-size child still
|
|
// consumes Wrap spacing and would double the visible gap.
|
|
Wrap(
|
|
spacing: 8,
|
|
runSpacing: 4,
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
children: [
|
|
if (retry && retryRunId(run) != null && canRetryRun(run))
|
|
RetryRunAction(
|
|
run: run,
|
|
gateway: gateway,
|
|
onRunChanged: onRunChanged,
|
|
onRunOpened: onRunOpened,
|
|
),
|
|
if (cancelRunId(run) != null && canCancelRun(run))
|
|
CancelRunAction(
|
|
run: run,
|
|
gateway: gateway,
|
|
onRunChanged: onRunChanged,
|
|
),
|
|
],
|
|
),
|
|
RunDecisionNotice(run: run, gateway: gateway, onRunChanged: onRunChanged),
|
|
],
|
|
);
|
|
}
|