merge(app): land pipeline link and retry in more menu
This commit is contained in:
@@ -439,6 +439,8 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
onPipelineFilterChanged: (id) => _delegate.goTo(
|
||||
id == null ? AppRoute.runs : AppRoute.runsForPipeline(id),
|
||||
),
|
||||
onOpenPipeline: (id, version) =>
|
||||
_delegate.goTo(AppRoute.pipeline(id, version: version)),
|
||||
),
|
||||
),
|
||||
AppDestination.chat: (_) => ChatDestination(
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import '../features/attention/notify/notification_controller.dart';
|
||||
import '../features/attention/runtime/attention_controller.dart';
|
||||
import '../features/runs/screen.dart';
|
||||
import '../features/runs/ui/run_pipeline_link.dart';
|
||||
import '../ui/adaptive/host.dart';
|
||||
import 'app_session.dart';
|
||||
import 'connection_status.dart';
|
||||
@@ -27,6 +28,7 @@ class RunsDestination extends StatelessWidget {
|
||||
this.onRunSelected,
|
||||
this.onBack,
|
||||
this.onPipelineFilterChanged,
|
||||
this.onOpenPipeline,
|
||||
this.listRefreshToken = 0,
|
||||
this.notifications,
|
||||
this.attention,
|
||||
@@ -50,6 +52,7 @@ class RunsDestination extends StatelessWidget {
|
||||
final ValueChanged<int>? onRunSelected;
|
||||
final ValueChanged<int?>? onBack;
|
||||
final ValueChanged<int?>? onPipelineFilterChanged;
|
||||
final OpenPipeline? onOpenPipeline;
|
||||
|
||||
/// Advances when a launch was accepted elsewhere. The mounted Runs screen
|
||||
/// re-reads its list once; no row is inserted locally.
|
||||
@@ -107,5 +110,6 @@ class RunsDestination extends StatelessWidget {
|
||||
onRunSelected: onRunSelected,
|
||||
onBack: onBack,
|
||||
onPipelineFilterChanged: onPipelineFilterChanged,
|
||||
onOpenPipeline: onOpenPipeline,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import '../data/runs_repository.dart';
|
||||
import 'action_refusal.dart';
|
||||
import 'retry_dialog.dart';
|
||||
import 'retry_eligibility.dart';
|
||||
import 'retry_intent.dart';
|
||||
import 'retry_wording.dart';
|
||||
|
||||
/// The run detail's deliberate retry entry point.
|
||||
@@ -42,26 +41,20 @@ class RetryRunAction extends StatefulWidget {
|
||||
|
||||
class _RetryRunActionState extends State<RetryRunAction> {
|
||||
bool _dialogOpen = false;
|
||||
Future<bool?>? _resync;
|
||||
|
||||
bool _usesCupertino(BuildContext context) {
|
||||
final material = Localizations.of<MaterialLocalizations>(
|
||||
context,
|
||||
MaterialLocalizations,
|
||||
);
|
||||
return material == null;
|
||||
}
|
||||
bool _usesCupertino(BuildContext context) => _cupertinoLocale(context);
|
||||
|
||||
Future<void> _open() async {
|
||||
final id = retryRunId(widget.run);
|
||||
if (id == null || !canRetryRun(widget.run) || _dialogOpen) return;
|
||||
if (_dialogOpen) return;
|
||||
_dialogOpen = true;
|
||||
try {
|
||||
await showRetryRunPrompt(
|
||||
context: context,
|
||||
runId: id,
|
||||
cupertino: _usesCupertino(context),
|
||||
onSubmit: (intent) => _submit(id, intent),
|
||||
await openRetryRunPrompt(
|
||||
context,
|
||||
run: widget.run,
|
||||
gateway: widget.gateway,
|
||||
onRunChanged: widget.onRunChanged,
|
||||
onRunOpened: widget.onRunOpened,
|
||||
owns: (id) => mounted && retryRunId(widget.run) == id,
|
||||
);
|
||||
} finally {
|
||||
_dialogOpen = false;
|
||||
@@ -69,51 +62,6 @@ class _RetryRunActionState extends State<RetryRunAction> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<ActionRefusal?> _submit(num id, RetryIntent intent) async {
|
||||
final repository = RunsRepository(widget.gateway);
|
||||
try {
|
||||
final run = await repository.retryRun(
|
||||
id,
|
||||
requestKey: intent.requestKey,
|
||||
mode: intent.mode.wireMode,
|
||||
);
|
||||
if (!mounted) return null;
|
||||
if (_owns(id)) {
|
||||
widget.onRunChanged(run);
|
||||
final opened = retryRunId(run);
|
||||
if (opened != null && opened != id) widget.onRunOpened?.call(opened);
|
||||
}
|
||||
return null;
|
||||
} catch (error) {
|
||||
return ActionRefusal(
|
||||
describeRetryError(error),
|
||||
stillPossible: _resyncRun(id),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
bool _owns(num id) => mounted && retryRunId(widget.run) == id;
|
||||
|
||||
/// One bounded re-read per refusal. A refusal that arrives while a read is
|
||||
/// already in flight observes that same read instead of starting another.
|
||||
Future<bool?> _resyncRun(num id) {
|
||||
return _resync ??= _readRun(id);
|
||||
}
|
||||
|
||||
Future<bool?> _readRun(num id) async {
|
||||
try {
|
||||
final run = await RunsRepository(widget.gateway).getRun(id);
|
||||
if (!_owns(id)) return null;
|
||||
widget.onRunChanged(run);
|
||||
return canRetryRun(run);
|
||||
} catch (_) {
|
||||
// Unknown server truth: keep the refusal and leave a deliberate retry.
|
||||
return null;
|
||||
} finally {
|
||||
_resync = null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (retryRunId(widget.run) == null || !canRetryRun(widget.run)) {
|
||||
@@ -134,3 +82,65 @@ class _RetryRunActionState extends State<RetryRunAction> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
bool _cupertinoLocale(BuildContext context) =>
|
||||
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations) ==
|
||||
null;
|
||||
|
||||
/// Opens the retry prompt for a failed [run]; only its confirm sends
|
||||
/// `retry_run`. An accepted reply reaches [onRunChanged] while [owns] still
|
||||
/// holds, and a new run id opens through [onRunOpened]. A refusal re-reads the
|
||||
/// run once so the prompt can say whether retrying is still possible. Shared
|
||||
/// by the button and the run detail's more menu.
|
||||
Future<void> openRetryRunPrompt(
|
||||
BuildContext context, {
|
||||
required JsonMap run,
|
||||
required ApiGateway gateway,
|
||||
required ValueChanged<JsonMap> onRunChanged,
|
||||
required bool Function(num id) owns,
|
||||
ValueChanged<num>? onRunOpened,
|
||||
}) async {
|
||||
final id = retryRunId(run);
|
||||
if (id == null || !canRetryRun(run)) return;
|
||||
final repository = RunsRepository(gateway);
|
||||
Future<bool?>? resync;
|
||||
Future<bool?> readRun() async {
|
||||
try {
|
||||
final current = await repository.getRun(id);
|
||||
if (!owns(id)) return null;
|
||||
onRunChanged(current);
|
||||
return canRetryRun(current);
|
||||
} catch (_) {
|
||||
// Unknown server truth: keep the refusal and leave a deliberate retry.
|
||||
return null;
|
||||
} finally {
|
||||
resync = null;
|
||||
}
|
||||
}
|
||||
|
||||
await showRetryRunPrompt(
|
||||
context: context,
|
||||
runId: id,
|
||||
cupertino: _cupertinoLocale(context),
|
||||
onSubmit: (intent) async {
|
||||
try {
|
||||
final updated = await repository.retryRun(
|
||||
id,
|
||||
requestKey: intent.requestKey,
|
||||
mode: intent.mode.wireMode,
|
||||
);
|
||||
if (owns(id)) {
|
||||
onRunChanged(updated);
|
||||
final opened = retryRunId(updated);
|
||||
if (opened != null && opened != id) onRunOpened?.call(opened);
|
||||
}
|
||||
return null;
|
||||
} catch (error) {
|
||||
return ActionRefusal(
|
||||
describeRetryError(error),
|
||||
stillPossible: resync ??= readRun(),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import '../attention/runtime/attention_store.dart';
|
||||
import 'actions/decision_action.dart';
|
||||
import 'data/runs_repository.dart';
|
||||
import 'domain/run_decisions.dart';
|
||||
import 'ui/run_pipeline_link.dart';
|
||||
import 'ui/run_detail_view.dart';
|
||||
import 'ui/runs_controller.dart';
|
||||
import 'ui/runs_list.dart';
|
||||
@@ -34,6 +35,7 @@ class RunsScreen extends StatefulWidget {
|
||||
this.onRunSelected,
|
||||
this.onBack,
|
||||
this.onPipelineFilterChanged,
|
||||
this.onOpenPipeline,
|
||||
this.attentionStore = const SharedPreferencesAttentionStore(),
|
||||
this.attentionNow,
|
||||
this.notifications,
|
||||
@@ -68,6 +70,9 @@ class RunsScreen extends StatefulWidget {
|
||||
final ValueChanged<int?>? onBack;
|
||||
final ValueChanged<int?>? onPipelineFilterChanged;
|
||||
|
||||
/// Opens a pipeline from the run detail's pipeline name.
|
||||
final OpenPipeline? onOpenPipeline;
|
||||
|
||||
/// Persisted attention dismissals and the clock for its local-day window.
|
||||
/// The app uses SharedPreferences; tests and fixtures inject a memory store.
|
||||
final AttentionStore attentionStore;
|
||||
@@ -249,6 +254,7 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
gateway: widget.gateway,
|
||||
onBack: _back,
|
||||
onRunOpened: _select,
|
||||
onOpenPipeline: widget.onOpenPipeline,
|
||||
initialStageKey: widget.initialStageKey,
|
||||
initialVisit: widget.initialVisit,
|
||||
),
|
||||
|
||||
@@ -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,
|
||||
],
|
||||
),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+38
-10
@@ -5,7 +5,8 @@ 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';
|
||||
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_pipeline_link.dart';
|
||||
|
||||
class _FakeGateway implements ApiGateway {
|
||||
_FakeGateway(this.detail);
|
||||
@@ -21,7 +22,12 @@ class _FakeGateway implements ApiGateway {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _pump(WidgetTester tester, String status, bool cupertino) async {
|
||||
Future<void> _pump(
|
||||
WidgetTester tester,
|
||||
String status,
|
||||
bool cupertino, {
|
||||
OpenPipeline? onOpenPipeline,
|
||||
}) async {
|
||||
tester.view.physicalSize = const Size(390, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
@@ -33,6 +39,8 @@ Future<void> _pump(WidgetTester tester, String status, bool cupertino) async {
|
||||
'name': 'nightly',
|
||||
'status': status,
|
||||
'executing': false,
|
||||
'pipeline_id': 10,
|
||||
'version': 3,
|
||||
}),
|
||||
),
|
||||
);
|
||||
@@ -41,6 +49,7 @@ Future<void> _pump(WidgetTester tester, String status, bool cupertino) async {
|
||||
controller: controller,
|
||||
gateway: _FakeGateway(const {}),
|
||||
onBack: () {},
|
||||
onOpenPipeline: onOpenPipeline,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
@@ -50,23 +59,42 @@ Future<void> _pump(WidgetTester tester, String status, bool cupertino) async {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<bool> _menuOffersRetry(WidgetTester tester) async {
|
||||
await tester.tap(find.byKey(runMoreMenuKey));
|
||||
await tester.pumpAndSettle();
|
||||
return find.text('Retry').evaluate().isNotEmpty;
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'cupertino' : 'material';
|
||||
testWidgets('$host: Retry sits beside the failed status', (tester) async {
|
||||
testWidgets('$host: Retry is a more-menu option for a failed run', (
|
||||
tester,
|
||||
) async {
|
||||
await _pump(tester, 'failed', cupertino);
|
||||
// Not in the header itself.
|
||||
expect(find.text('Retry'), findsNothing);
|
||||
expect(await _menuOffersRetry(tester), isTrue);
|
||||
});
|
||||
|
||||
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: the pipeline name opens that pipeline at the run\'s '
|
||||
'version', (tester) async {
|
||||
final opened = <(int, int)>[];
|
||||
await _pump(
|
||||
tester,
|
||||
'succeeded',
|
||||
cupertino,
|
||||
onOpenPipeline: (id, version) => opened.add((id, version)),
|
||||
);
|
||||
await tester.tap(find.byKey(runPipelineLinkKey));
|
||||
await tester.pump();
|
||||
expect(opened, [(10, 3)]);
|
||||
expect(find.bySemanticsLabel('Open pipeline nightly'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('$host: a succeeded run offers no Retry', (tester) async {
|
||||
await _pump(tester, 'succeeded', cupertino);
|
||||
expect(find.text('Retry'), findsNothing);
|
||||
expect(await _menuOffersRetry(tester), isFalse);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ void main() {
|
||||
expect(find.text(retryFailedTitle), findsOneWidget);
|
||||
await tester.tap(find.byKey(retryKeepKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(retryActionKey), findsOneWidget);
|
||||
expect(await retryOffered(tester), isTrue);
|
||||
});
|
||||
|
||||
testWidgets('a retry reply that lands after leaving is ignored', (
|
||||
@@ -109,6 +109,6 @@ void main() {
|
||||
await mountRetryScreen(tester, gateway, cupertino: false);
|
||||
|
||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||
expect(find.byKey(retryActionKey), findsNothing);
|
||||
expect(await retryOffered(tester), isFalse);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/retry_wording.dart';
|
||||
import 'package:pipelines_app/features/runs/screen.dart';
|
||||
@@ -105,9 +106,27 @@ Future<void> mountRetryScreen(
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> confirmRetry(WidgetTester tester) async {
|
||||
/// Retry lives in the run detail's more menu.
|
||||
Future<void> openRetry(WidgetTester tester) async {
|
||||
await tester.tap(find.byKey(runMoreMenuKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(retryActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
/// Whether the more menu offers Retry; the menu is closed again afterwards.
|
||||
Future<bool> retryOffered(WidgetTester tester) async {
|
||||
if (find.byKey(runMoreMenuKey).evaluate().isEmpty) return false;
|
||||
await tester.tap(find.byKey(runMoreMenuKey));
|
||||
await tester.pumpAndSettle();
|
||||
final offered = find.byKey(retryActionKey).evaluate().isNotEmpty;
|
||||
await tester.tapAt(const Offset(2, 2));
|
||||
await tester.pumpAndSettle();
|
||||
return offered;
|
||||
}
|
||||
|
||||
Future<void> confirmRetry(WidgetTester tester) async {
|
||||
await openRetry(tester);
|
||||
await tester.tap(find.byKey(retryConfirmKey));
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
@@ -22,12 +22,11 @@ void main() {
|
||||
|
||||
expect(find.text(retryFailedTitle), findsOneWidget);
|
||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||
expect(find.byKey(retryActionKey), findsOneWidget);
|
||||
expect(await retryOffered(tester), isTrue);
|
||||
expect(find.byKey(cancelActionKey), findsNothing);
|
||||
expect(gateway.retryCalls, isEmpty);
|
||||
|
||||
await tester.tap(find.byKey(retryActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
await openRetry(tester);
|
||||
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
||||
expect(find.text(retryDialogMessage), findsOneWidget);
|
||||
expect(gateway.retryCalls, isEmpty);
|
||||
@@ -36,7 +35,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.retryCalls, isEmpty);
|
||||
expect(opened, isEmpty);
|
||||
expect(find.byKey(retryActionKey), findsOneWidget);
|
||||
expect(await retryOffered(tester), isTrue);
|
||||
|
||||
await confirmRetry(tester);
|
||||
expect(gateway.retryCalls, hasLength(1));
|
||||
@@ -58,7 +57,7 @@ void main() {
|
||||
expect(opened, [8]);
|
||||
expect(find.text(retryCreatedTitle), findsOneWidget);
|
||||
expect(find.text(retryFailedTitle), findsNothing);
|
||||
expect(find.byKey(retryActionKey), findsNothing);
|
||||
expect(await retryOffered(tester), isFalse);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'get_run').last.fields,
|
||||
{'run_id': 8},
|
||||
@@ -80,8 +79,7 @@ void main() {
|
||||
onRunSelected: opened.add,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(retryActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
await openRetry(tester);
|
||||
await tester.tap(find.byKey(retryRestartKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(restartDialogTitle(7)), findsOneWidget);
|
||||
|
||||
Reference in New Issue
Block a user