266916f92a
- Select mode (bar Select or long-press): per-row checkboxes, per-day
Select all/Deselect all over finished runs only, "N selected" with the
selection size, Delete and Done. Active runs get a disabled checkbox
whose semantics give the reason.
- Native destructive confirmation, then delete_runs {run_ids} (batched by
1000); the nested runs_deleted reply removes deleted rows and reports
"Deleted N runs, freed X" plus refusals verbatim. runs_removed pushes
remove rows and close an open detail; a deleted open run closes too.
Delete run in the row and detail menus.
- size_bytes shown compactly in rows (0/absent = unknown, nothing shown),
updated from run_event frames that carry it; Largest first sort (flat,
unknowns last); the sort choice persists.
- Shared AppListRow gains selectionControl and onLongPress.
- Browser probe tool/runs_delete_probe.mjs; fixture server implements
delete_runs/runs_removed.
146 lines
4.8 KiB
Dart
146 lines
4.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../ui/layout/app_overflow_menu.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../../schedules/ui/run/schedule_run_action.dart';
|
|
import '../actions/delete_runs_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';
|
|
import '../domain/run_deletion.dart';
|
|
import '../domain/run_models.dart' show runIdentity;
|
|
|
|
const runMoreMenuKey = ValueKey<String>('run-more-menu');
|
|
const deleteRunActionKey = ValueKey<String>('run-delete-action');
|
|
const deleteRunActionLabel = 'Delete run';
|
|
|
|
/// Whether the run has anything for its more menu. [deletable] says the host
|
|
/// can apply a deletion, so a finished run offers Delete run.
|
|
bool showRunMoreMenu(JsonMap run, {bool deletable = false}) =>
|
|
runTitleId(run) != null ||
|
|
canScheduleRun(run) ||
|
|
_canRetry(run) ||
|
|
(deletable && runIsDeletable(run));
|
|
|
|
/// The run's own name for its action sheet: its title or pipeline, else
|
|
/// `Run <id>`, as its list row shows it.
|
|
String runMoreMenuTitle(JsonMap run) {
|
|
final label = runIdentity(run['title'], run['name']).label;
|
|
return label.isEmpty ? 'Run ${run['id']}' : label;
|
|
}
|
|
|
|
bool _canRetry(JsonMap run) => retryRunId(run) != null && canRetryRun(run);
|
|
|
|
enum _RunMoreItem { retry, rename, schedule, delete }
|
|
|
|
/// Each item keeps the key its standalone button had.
|
|
Key _keyOf(_RunMoreItem item) => switch (item) {
|
|
_RunMoreItem.retry => retryActionKey,
|
|
_RunMoreItem.rename => runTitleActionKey,
|
|
_RunMoreItem.schedule => scheduleRunActionKey,
|
|
_RunMoreItem.delete => deleteRunActionKey,
|
|
};
|
|
|
|
/// 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 {
|
|
const RunMoreMenu({
|
|
super.key,
|
|
required this.run,
|
|
required this.gateway,
|
|
required this.onRunChanged,
|
|
required this.cupertino,
|
|
this.onRunOpened,
|
|
this.onDeleted,
|
|
this.menuKey = runMoreMenuKey,
|
|
});
|
|
|
|
final JsonMap run;
|
|
final ApiGateway gateway;
|
|
final ValueChanged<JsonMap> onRunChanged;
|
|
final bool cupertino;
|
|
|
|
/// Opens the new run an accepted retry names.
|
|
final ValueChanged<num>? onRunOpened;
|
|
|
|
/// Applies an answered deletion; without it the menu offers no Delete run.
|
|
final ValueChanged<RunsDeletion>? onDeleted;
|
|
|
|
/// Detail menus retain the shared key; list rows supply a per-run key.
|
|
final Key menuKey;
|
|
|
|
@override
|
|
State<RunMoreMenu> createState() => _RunMoreMenuState();
|
|
}
|
|
|
|
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),
|
|
if (widget.onDeleted != null && runIsDeletable(run))
|
|
(_RunMoreItem.delete, deleteRunActionLabel),
|
|
];
|
|
|
|
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,
|
|
run: run,
|
|
gateway: widget.gateway,
|
|
onRunChanged: widget.onRunChanged,
|
|
// The latest run, so a result for a run no longer shown is dropped.
|
|
owns: (owned) => mounted && runTitleId(widget.run) == owned,
|
|
);
|
|
case _RunMoreItem.schedule:
|
|
openScheduleRunEditor(context, run: run, gateway: widget.gateway);
|
|
case _RunMoreItem.delete:
|
|
confirmDeleteRuns(
|
|
context,
|
|
runs: [run],
|
|
gateway: widget.gateway,
|
|
onDeleted: widget.onDeleted!,
|
|
cupertino: widget.cupertino,
|
|
);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AppOverflowMenu<_RunMoreItem>(
|
|
key: widget.menuKey,
|
|
cupertino: widget.cupertino,
|
|
// The Cupertino action sheet names the run it acts on.
|
|
sheetTitle: runMoreMenuTitle(run),
|
|
actions: [
|
|
for (final (item, label) in _items)
|
|
AppMenuAction(
|
|
key: _keyOf(item),
|
|
value: item,
|
|
label: label,
|
|
destructive: item == _RunMoreItem.delete,
|
|
),
|
|
],
|
|
onSelected: _pick,
|
|
);
|
|
}
|
|
}
|