9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
151 lines
5.1 KiB
Dart
151 lines
5.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../ui/adaptive/segmented_bar.dart';
|
|
import '../../../core/api_gateway.dart';
|
|
import '../../changes/changes.dart';
|
|
|
|
/// The run detail's action and page label. The viewer itself owns the
|
|
/// recorded summary and capture wording, so this bar stays neutral.
|
|
const runChangesLabel = 'Changes';
|
|
const runChangesButtonKey = ValueKey<String>('run-detail-changes');
|
|
const runVisitChangesButtonKey = ValueKey<String>('run-visit-changes');
|
|
|
|
/// The detail's `steps` exactly as returned by the server. The pushed page
|
|
/// snapshots the returned list once, so it never re-derives on each rebuild.
|
|
List<JsonMap> runDetailChangeSteps(JsonMap run) {
|
|
final steps = run['steps'];
|
|
if (steps is List<JsonMap>) return steps;
|
|
if (steps is List) return steps.cast<JsonMap>();
|
|
return const <JsonMap>[];
|
|
}
|
|
|
|
const _executingStatuses = {'queued', 'running', 'waiting'};
|
|
|
|
/// Whether the run detail offers the action at all. The opened page is a
|
|
/// snapshot of the recorded steps, so it is offered only once nothing is
|
|
/// executing: the server's own `executing` flag (which can stay true on a
|
|
/// failed run whose step is still active) or a queued/running/waiting status
|
|
/// would otherwise show a page that silently goes stale.
|
|
bool showRunChangesAction(JsonMap run) =>
|
|
run['executing'] != true &&
|
|
!_executingStatuses.contains('${run['status'] ?? ''}'.trim().toLowerCase());
|
|
|
|
/// A standard native button for the run detail body. It opens the recorded
|
|
/// changes in a platform page whose single navigation bar is the only chrome.
|
|
class RunChangesButton extends StatelessWidget {
|
|
const RunChangesButton({super.key, required this.run});
|
|
|
|
final JsonMap run;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final steps = runDetailChangeSteps(run);
|
|
// The web client shows the run-wide aggregate only for a succeeded run; a
|
|
// failed run still keeps each visit's own recorded capture.
|
|
final summary = showRunChangesSummary(run['status']);
|
|
void open() => showRunChanges(context, steps: steps, showSummary: summary);
|
|
return OutlinedButton.icon(
|
|
key: runChangesButtonKey,
|
|
onPressed: open,
|
|
icon: const Icon(Icons.difference_outlined),
|
|
label: const Text(runChangesLabel),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Opens the already-landed [ChangesViewer] for [steps] on a native page.
|
|
/// The bar is the one title bar; the viewer's own summary and capture facts
|
|
/// are passed through untouched, except for the caller's [showSummary] gate.
|
|
///
|
|
/// [title] names the evidence the page shows. The run-level action keeps the
|
|
/// neutral [runChangesLabel]; a visit passes [visitChangesTitle] so the pushed
|
|
/// page cannot be mistaken for the run-wide aggregate.
|
|
Future<void> showRunChanges(
|
|
BuildContext context, {
|
|
required List<JsonMap> steps,
|
|
required bool showSummary,
|
|
String title = runChangesLabel,
|
|
}) {
|
|
return Navigator.of(context).push<void>(
|
|
MaterialPageRoute<void>(
|
|
builder: (_) => _MaterialChangesPage(
|
|
steps: steps,
|
|
showSummary: showSummary,
|
|
title: title,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// The page identity for exactly one recorded visit: the stage and visit the
|
|
/// timeline row shows, so the page names its evidence rather than the run.
|
|
String visitChangesTitle(String stage, int? sequence) {
|
|
final name = stage.trim();
|
|
final visit = sequence == null ? 'visit unavailable' : 'visit $sequence';
|
|
return name.isEmpty
|
|
? '$runChangesLabel · $visit'
|
|
: '$runChangesLabel · $name · $visit';
|
|
}
|
|
|
|
/// Opens the Changes viewer for exactly one visit's recorded [step].
|
|
///
|
|
/// The page shows that step's own capture only - never the run's other visits -
|
|
/// and no run-wide final-state header, which belongs to the run-level action.
|
|
Future<void> showVisitChanges(
|
|
BuildContext context, {
|
|
required String stage,
|
|
required int? sequence,
|
|
required JsonMap step,
|
|
}) => showRunChanges(
|
|
context,
|
|
steps: <JsonMap>[step],
|
|
showSummary: false,
|
|
title: visitChangesTitle(stage, sequence),
|
|
);
|
|
|
|
/// The opened visit pane's own native action. It passes only the visit's step,
|
|
/// so the viewer's per-stage section is its single evidence entry.
|
|
class RunVisitChangesButton extends StatelessWidget {
|
|
const RunVisitChangesButton({
|
|
super.key,
|
|
required this.stage,
|
|
required this.sequence,
|
|
required this.step,
|
|
});
|
|
|
|
final String stage;
|
|
final int? sequence;
|
|
final JsonMap step;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
void open() =>
|
|
showVisitChanges(context, stage: stage, sequence: sequence, step: step);
|
|
return TextButton.icon(
|
|
key: runVisitChangesButtonKey,
|
|
onPressed: open,
|
|
icon: const Icon(Icons.difference_outlined),
|
|
label: const Text(runChangesLabel),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _MaterialChangesPage extends StatelessWidget {
|
|
const _MaterialChangesPage({
|
|
required this.steps,
|
|
required this.showSummary,
|
|
required this.title,
|
|
});
|
|
|
|
final List<JsonMap> steps;
|
|
final bool showSummary;
|
|
final String title;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Scaffold(
|
|
extendBodyBehindAppBar: true,
|
|
appBar: SegmentedBar(title: title),
|
|
body: ChangesViewer(steps: steps, showSummary: showSummary),
|
|
);
|
|
}
|