feat(app): the run dialog can continue to a schedule editor seeded with its prompt
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import '../../schedules/data/schedules_repository.dart';
|
||||
import '../../schedules/domain/editor/schedule_draft.dart';
|
||||
import '../../schedules/ui/pipeline/schedule_pipeline_editor.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -24,6 +27,19 @@ Future<void> showRunPipelineDialog({
|
||||
required ValueChanged<RunPipelineIntent?> onPendingChanged,
|
||||
required ValueChanged<JsonMap> onAccepted,
|
||||
}) {
|
||||
// Schedule instead: the editor opens as the next page from the screen that
|
||||
// opened this dialog, seeded with what was typed here.
|
||||
Future<void> schedule(ScheduleDraft draft) {
|
||||
final requestKey = newScheduleCreateRequestKey();
|
||||
final repository = SchedulesRepository(gateway);
|
||||
return openSchedulePipelineEditor(
|
||||
context,
|
||||
draft: draft,
|
||||
onSubmit: (record) =>
|
||||
repository.saveSchedule(record, requestKey: requestKey),
|
||||
);
|
||||
}
|
||||
|
||||
final dialog = _RunPipelineDialog(
|
||||
detail: detail,
|
||||
gateway: gateway,
|
||||
@@ -32,6 +48,7 @@ Future<void> showRunPipelineDialog({
|
||||
onSubmit: onSubmit,
|
||||
onPendingChanged: onPendingChanged,
|
||||
onAccepted: onAccepted,
|
||||
onSchedule: schedule,
|
||||
);
|
||||
return dialog.cupertino
|
||||
? showCupertinoDialog<void>(
|
||||
@@ -55,8 +72,11 @@ class _RunPipelineDialog extends StatefulWidget {
|
||||
required this.onSubmit,
|
||||
required this.onPendingChanged,
|
||||
required this.onAccepted,
|
||||
required this.onSchedule,
|
||||
});
|
||||
|
||||
final Future<void> Function(ScheduleDraft draft) onSchedule;
|
||||
|
||||
final PipelineDetail detail;
|
||||
final ApiGateway gateway;
|
||||
final RunPipelineIntent? pending;
|
||||
@@ -213,6 +233,11 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
|
||||
onPressed: _sending ? null : _cancel,
|
||||
child: const Text(runPipelineCancelLabel),
|
||||
),
|
||||
TextButton(
|
||||
key: const Key('run-pipeline-schedule'),
|
||||
onPressed: _sending ? null : _schedule,
|
||||
child: const Text('Schedule…'),
|
||||
),
|
||||
FilledButton(
|
||||
key: runPipelineConfirmKey,
|
||||
onPressed: _sending ? null : _confirm,
|
||||
@@ -232,6 +257,11 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
|
||||
onPressed: _sending ? null : _cancel,
|
||||
child: const Text(runPipelineCancelLabel),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: const Key('run-pipeline-schedule'),
|
||||
onPressed: _sending ? null : _schedule,
|
||||
child: const Text('Schedule…'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: runPipelineConfirmKey,
|
||||
isDefaultAction: true,
|
||||
@@ -242,6 +272,19 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
|
||||
);
|
||||
}
|
||||
|
||||
/// Leaves the dialog for the schedule editor with the typed prompt,
|
||||
/// workspace and the pinned version.
|
||||
void _schedule() {
|
||||
final draft = ScheduleDraft.create(
|
||||
pipelineId: widget.detail.id,
|
||||
version: '${widget.detail.resolvedVersion}',
|
||||
workspace: _workspace.text.trim(),
|
||||
)..prompt = _prompt.text;
|
||||
final schedule = widget.onSchedule;
|
||||
Navigator.of(context).pop();
|
||||
schedule(draft);
|
||||
}
|
||||
|
||||
String get _confirmLabel {
|
||||
if (_sending) return runPipelineSendingLabel;
|
||||
return _intent == null
|
||||
|
||||
Reference in New Issue
Block a user