feat(app): Rename and Schedule this run move into the run detail's more menu
This commit is contained in:
@@ -23,6 +23,25 @@ bool canScheduleRun(JsonMap run) =>
|
||||
|
||||
bool _positive(int? value) => value != null && value > 0;
|
||||
|
||||
/// Opens the create editor over [ScheduleDraft.fromRun]; nothing is sent until
|
||||
/// Save. One request key is minted per opening, so retrying a refused save
|
||||
/// cannot create a duplicate. Shared by the button and the run's more menu.
|
||||
Future<void> openScheduleRunEditor(
|
||||
BuildContext context, {
|
||||
required JsonMap run,
|
||||
required ApiGateway gateway,
|
||||
}) async {
|
||||
if (!canScheduleRun(run)) return;
|
||||
final requestKey = newScheduleCreateRequestKey();
|
||||
final repository = SchedulesRepository(gateway);
|
||||
await openSchedulePipelineEditor(
|
||||
context,
|
||||
draft: ScheduleDraft.fromRun(run),
|
||||
onSubmit: (record) =>
|
||||
repository.saveSchedule(record, requestKey: requestKey),
|
||||
);
|
||||
}
|
||||
|
||||
/// The run detail's "Schedule this run" action.
|
||||
///
|
||||
/// Pressing it only opens the landed create editor over [ScheduleDraft.fromRun]:
|
||||
@@ -49,17 +68,13 @@ class _ScheduleRunActionState extends State<ScheduleRunAction> {
|
||||
bool _opening = false;
|
||||
|
||||
Future<void> _open() async {
|
||||
if (_opening || !canScheduleRun(widget.run)) return;
|
||||
if (_opening) return;
|
||||
_opening = true;
|
||||
// Minted once for this editor; every retry inside it reuses the key.
|
||||
final requestKey = newScheduleCreateRequestKey();
|
||||
final repository = SchedulesRepository(widget.gateway);
|
||||
try {
|
||||
await openSchedulePipelineEditor(
|
||||
await openScheduleRunEditor(
|
||||
context,
|
||||
draft: ScheduleDraft.fromRun(widget.run),
|
||||
onSubmit: (record) =>
|
||||
repository.saveSchedule(record, requestKey: requestKey),
|
||||
run: widget.run,
|
||||
gateway: widget.gateway,
|
||||
);
|
||||
} finally {
|
||||
_opening = false;
|
||||
|
||||
Reference in New Issue
Block a user