Files
pipelines/app/lib/features/runs/actions/delete_runs_action.dart
T
alan 9551eceaed Complete Material-only APIs and fixtures
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.
2026-11-11 21:55:39 +00:00

39 lines
1.2 KiB
Dart

import 'package:flutter/widgets.dart';
import '../../../core/api_gateway.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,
}) {
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),
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;
}
},
);
}