Files
pipelines/app/lib/features/runs/actions/delete_runs_action.dart
T
alan 266916f92a Runs: multi-select delete, run sizes and Largest-first sort
- 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.
2026-10-31 22:19:36 +00:00

42 lines
1.3 KiB
Dart

import 'package:flutter/widgets.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/host.dart';
import '../data/runs_repository.dart';
import '../domain/run_deletion.dart';
import 'delete_runs_dialog.dart';
/// Confirms and deletes the finished runs among [runs].
///
/// Active runs are left out; nothing is sent unless the operator confirms. A
/// transport or server error stays in the open prompt. The server's reply,
/// including any refusals, goes to [onDeleted] exactly as received.
Future<bool> confirmDeleteRuns(
BuildContext context, {
required Iterable<JsonMap> runs,
required ApiGateway gateway,
required ValueChanged<RunsDeletion> onDeleted,
bool? cupertino,
}) {
final deletable = runs.where(runIsDeletable).toList();
final ids = deletableRunIds(deletable);
if (ids.isEmpty) return Future.value(false);
return showDeleteRunsPrompt(
context: context,
count: ids.length,
size: runsSizeLabel(deletable),
cupertino: cupertino ?? usesCupertinoHost(context),
onSubmit: () async {
try {
onDeleted(await RunsRepository(gateway).deleteRuns(ids));
return null;
} catch (error) {
final message = '$error'.trim();
return message.isEmpty
? 'The server did not delete the runs.'
: message;
}
},
);
}