feat(app): add report format to pipeline launch
This commit is contained in:
@@ -21,6 +21,18 @@ enum RunNotifyMode {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Optional report requirement requested for a manually started run.
|
||||||
|
enum RunOutputFormat {
|
||||||
|
none('No report requirement', ''),
|
||||||
|
html('HTML report', 'html'),
|
||||||
|
markdown('Markdown report', 'markdown');
|
||||||
|
|
||||||
|
const RunOutputFormat(this.label, this.wireValue);
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
final String wireValue;
|
||||||
|
}
|
||||||
|
|
||||||
/// One confirmed launch intent: the pinned pipeline identity, the operator's
|
/// One confirmed launch intent: the pinned pipeline identity, the operator's
|
||||||
/// fields and the idempotency key that belongs to them.
|
/// fields and the idempotency key that belongs to them.
|
||||||
///
|
///
|
||||||
@@ -34,6 +46,7 @@ class RunPipelineIntent {
|
|||||||
required this.prompt,
|
required this.prompt,
|
||||||
required this.workspace,
|
required this.workspace,
|
||||||
required this.notifyMode,
|
required this.notifyMode,
|
||||||
|
this.outputFormat = RunOutputFormat.none,
|
||||||
required this.requestKey,
|
required this.requestKey,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -42,6 +55,7 @@ class RunPipelineIntent {
|
|||||||
final String prompt;
|
final String prompt;
|
||||||
final String workspace;
|
final String workspace;
|
||||||
final RunNotifyMode notifyMode;
|
final RunNotifyMode notifyMode;
|
||||||
|
final RunOutputFormat outputFormat;
|
||||||
final String requestKey;
|
final String requestKey;
|
||||||
|
|
||||||
/// The same key is only ever reused for the same pinned definition.
|
/// The same key is only ever reused for the same pinned definition.
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ class _RunPipelineActionState extends State<RunPipelineAction> {
|
|||||||
workspace: intent.workspace,
|
workspace: intent.workspace,
|
||||||
requestKey: intent.requestKey,
|
requestKey: intent.requestKey,
|
||||||
notifyMode: intent.notifyMode.wireValue,
|
notifyMode: intent.notifyMode.wireValue,
|
||||||
|
outputFormat: intent.outputFormat.wireValue,
|
||||||
);
|
);
|
||||||
final accepted = _accept(run);
|
final accepted = _accept(run);
|
||||||
if (accepted is RunPipelineAccepted) return accepted;
|
if (accepted is RunPipelineAccepted) return accepted;
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
|
|||||||
late final TextEditingController _prompt;
|
late final TextEditingController _prompt;
|
||||||
late final TextEditingController _workspace;
|
late final TextEditingController _workspace;
|
||||||
late RunNotifyMode _notify;
|
late RunNotifyMode _notify;
|
||||||
|
late RunOutputFormat _outputFormat;
|
||||||
late RunPipelineIntent? _intent;
|
late RunPipelineIntent? _intent;
|
||||||
bool _sending = false;
|
bool _sending = false;
|
||||||
String? _error;
|
String? _error;
|
||||||
@@ -83,6 +84,7 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
|
|||||||
: null;
|
: null;
|
||||||
_intent = restored;
|
_intent = restored;
|
||||||
_notify = restored?.notifyMode ?? RunNotifyMode.pipelineDefault;
|
_notify = restored?.notifyMode ?? RunNotifyMode.pipelineDefault;
|
||||||
|
_outputFormat = restored?.outputFormat ?? RunOutputFormat.none;
|
||||||
_prompt = TextEditingController(text: restored?.prompt ?? '');
|
_prompt = TextEditingController(text: restored?.prompt ?? '');
|
||||||
_workspace = TextEditingController(text: restored?.workspace ?? '');
|
_workspace = TextEditingController(text: restored?.workspace ?? '');
|
||||||
_error = restored == null ? null : runPipelineUnknownAdmission;
|
_error = restored == null ? null : runPipelineUnknownAdmission;
|
||||||
@@ -122,6 +124,7 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
|
|||||||
prompt: prompt,
|
prompt: prompt,
|
||||||
workspace: workspace.trim(),
|
workspace: workspace.trim(),
|
||||||
notifyMode: _notify,
|
notifyMode: _notify,
|
||||||
|
outputFormat: _outputFormat,
|
||||||
requestKey: newRunPipelineRequestKey(
|
requestKey: newRunPipelineRequestKey(
|
||||||
widget.detail.id,
|
widget.detail.id,
|
||||||
widget.detail.resolvedVersion,
|
widget.detail.resolvedVersion,
|
||||||
@@ -214,8 +217,11 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
|
|||||||
prompt: _prompt,
|
prompt: _prompt,
|
||||||
workspace: _workspace,
|
workspace: _workspace,
|
||||||
notifyMode: _notify,
|
notifyMode: _notify,
|
||||||
|
outputFormat: _outputFormat,
|
||||||
locked: _locked,
|
locked: _locked,
|
||||||
onNotifyChanged: (mode) => setState(() => _notify = mode),
|
onNotifyChanged: (mode) => setState(() => _notify = mode),
|
||||||
|
onOutputFormatChanged: (format) =>
|
||||||
|
setState(() => _outputFormat = format),
|
||||||
),
|
),
|
||||||
if (_error case final error?)
|
if (_error case final error?)
|
||||||
Padding(
|
Padding(
|
||||||
|
|||||||
@@ -15,15 +15,19 @@ class RunPipelineFields extends StatelessWidget {
|
|||||||
required this.prompt,
|
required this.prompt,
|
||||||
required this.workspace,
|
required this.workspace,
|
||||||
required this.notifyMode,
|
required this.notifyMode,
|
||||||
|
required this.outputFormat,
|
||||||
required this.locked,
|
required this.locked,
|
||||||
required this.onNotifyChanged,
|
required this.onNotifyChanged,
|
||||||
|
required this.onOutputFormatChanged,
|
||||||
});
|
});
|
||||||
|
|
||||||
final TextEditingController prompt;
|
final TextEditingController prompt;
|
||||||
final TextEditingController workspace;
|
final TextEditingController workspace;
|
||||||
final RunNotifyMode notifyMode;
|
final RunNotifyMode notifyMode;
|
||||||
|
final RunOutputFormat outputFormat;
|
||||||
final bool locked;
|
final bool locked;
|
||||||
final ValueChanged<RunNotifyMode> onNotifyChanged;
|
final ValueChanged<RunNotifyMode> onNotifyChanged;
|
||||||
|
final ValueChanged<RunOutputFormat> onOutputFormatChanged;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -41,6 +45,10 @@ class RunPipelineFields extends StatelessWidget {
|
|||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
_FieldLabel(runPipelineNotifyLabel, cupertino: cupertino),
|
_FieldLabel(runPipelineNotifyLabel, cupertino: cupertino),
|
||||||
_notifyField(context, cupertino),
|
_notifyField(context, cupertino),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
_FieldLabel(runPipelineOutputFormatLabel, cupertino: cupertino),
|
||||||
|
_outputFormatField(context, cupertino),
|
||||||
|
_helper(context, runPipelineOutputFormatHelper, cupertino),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -156,6 +164,61 @@ class RunPipelineFields extends StatelessWidget {
|
|||||||
if (chosen != null) onNotifyChanged(chosen);
|
if (chosen != null) onNotifyChanged(chosen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _outputFormatField(BuildContext context, bool cupertino) {
|
||||||
|
if (cupertino) {
|
||||||
|
return CupertinoButton(
|
||||||
|
key: runPipelineOutputFormatKey,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
alignment: AlignmentDirectional.centerStart,
|
||||||
|
onPressed: locked ? null : () => _chooseOutputFormat(context),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Flexible(child: Text(outputFormat.label)),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
const Icon(CupertinoIcons.chevron_down, size: 14),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return DropdownButtonFormField<RunOutputFormat>(
|
||||||
|
key: runPipelineOutputFormatKey,
|
||||||
|
initialValue: outputFormat,
|
||||||
|
decoration: const InputDecoration(border: OutlineInputBorder()),
|
||||||
|
items: [
|
||||||
|
for (final format in RunOutputFormat.values)
|
||||||
|
DropdownMenuItem(value: format, child: Text(format.label)),
|
||||||
|
],
|
||||||
|
onChanged: locked
|
||||||
|
? null
|
||||||
|
: (format) {
|
||||||
|
if (format != null) onOutputFormatChanged(format);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _chooseOutputFormat(BuildContext context) async {
|
||||||
|
final chosen = await showCupertinoModalPopup<RunOutputFormat>(
|
||||||
|
context: context,
|
||||||
|
builder: (sheetContext) => CupertinoActionSheet(
|
||||||
|
title: const Text(runPipelineOutputFormatLabel),
|
||||||
|
actions: [
|
||||||
|
for (final format in RunOutputFormat.values)
|
||||||
|
CupertinoActionSheetAction(
|
||||||
|
onPressed: () => Navigator.of(sheetContext).pop(format),
|
||||||
|
child: Text(format.label),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
cancelButton: CupertinoActionSheetAction(
|
||||||
|
isDefaultAction: true,
|
||||||
|
onPressed: () => Navigator.of(sheetContext).pop(),
|
||||||
|
child: const Text(runPipelineCancelLabel),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (chosen != null) onOutputFormatChanged(chosen);
|
||||||
|
}
|
||||||
|
|
||||||
TextStyle _cupertinoPlaceholder(BuildContext context) {
|
TextStyle _cupertinoPlaceholder(BuildContext context) {
|
||||||
// The host's own dynamic placeholder colour (light and dark), resolved for
|
// The host's own dynamic placeholder colour (light and dark), resolved for
|
||||||
// the dialog's inherited Cupertino brightness.
|
// the dialog's inherited Cupertino brightness.
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ const runPipelineWorkspaceHelper =
|
|||||||
'Choose a recent directory or type an absolute path.';
|
'Choose a recent directory or type an absolute path.';
|
||||||
const runPipelineWorkspacePlaceholder = '/absolute/path/on/the/server';
|
const runPipelineWorkspacePlaceholder = '/absolute/path/on/the/server';
|
||||||
const runPipelineNotifyLabel = 'Notifications for this run';
|
const runPipelineNotifyLabel = 'Notifications for this run';
|
||||||
|
const runPipelineOutputFormatLabel = 'Report format';
|
||||||
|
const runPipelineOutputFormatHelper =
|
||||||
|
'Requires a nonempty server-written report before success. Structure only; facts are not verified.';
|
||||||
const runPipelineCancelLabel = 'Cancel';
|
const runPipelineCancelLabel = 'Cancel';
|
||||||
const runPipelineConfirmLabel = 'Run';
|
const runPipelineConfirmLabel = 'Run';
|
||||||
const runPipelineSendingLabel = 'Starting…';
|
const runPipelineSendingLabel = 'Starting…';
|
||||||
@@ -37,6 +40,7 @@ const runPipelineActionKey = ValueKey<String>('run-pipeline-action');
|
|||||||
const runPipelinePromptKey = ValueKey<String>('run-pipeline-prompt');
|
const runPipelinePromptKey = ValueKey<String>('run-pipeline-prompt');
|
||||||
const runPipelineWorkspaceKey = ValueKey<String>('run-pipeline-workspace');
|
const runPipelineWorkspaceKey = ValueKey<String>('run-pipeline-workspace');
|
||||||
const runPipelineNotifyKey = ValueKey<String>('run-pipeline-notify');
|
const runPipelineNotifyKey = ValueKey<String>('run-pipeline-notify');
|
||||||
|
const runPipelineOutputFormatKey = ValueKey<String>('run-pipeline-output-format');
|
||||||
const runPipelineCancelKey = ValueKey<String>('run-pipeline-cancel');
|
const runPipelineCancelKey = ValueKey<String>('run-pipeline-cancel');
|
||||||
const runPipelineConfirmKey = ValueKey<String>('run-pipeline-confirm');
|
const runPipelineConfirmKey = ValueKey<String>('run-pipeline-confirm');
|
||||||
const runPipelineErrorKey = ValueKey<String>('run-pipeline-error');
|
const runPipelineErrorKey = ValueKey<String>('run-pipeline-error');
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ void main() {
|
|||||||
expect(find.text(runPipelinePromptLabel), findsOneWidget);
|
expect(find.text(runPipelinePromptLabel), findsOneWidget);
|
||||||
expect(find.text(runPipelineWorkspaceLabel), findsOneWidget);
|
expect(find.text(runPipelineWorkspaceLabel), findsOneWidget);
|
||||||
expect(find.text(runPipelineNotifyLabel), findsOneWidget);
|
expect(find.text(runPipelineNotifyLabel), findsOneWidget);
|
||||||
|
expect(find.text(runPipelineOutputFormatLabel), findsOneWidget);
|
||||||
|
expect(find.text(runPipelineOutputFormatHelper), findsOneWidget);
|
||||||
expect(find.text(runPipelineCancelLabel), findsOneWidget);
|
expect(find.text(runPipelineCancelLabel), findsOneWidget);
|
||||||
expect(
|
expect(
|
||||||
find.descendant(
|
find.descendant(
|
||||||
@@ -112,6 +114,10 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.text('Silent').last);
|
await tester.tap(find.text('Silent').last);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.byKey(runPipelineOutputFormatKey));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('HTML report').last);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.byKey(runPipelineConfirmKey));
|
await tester.tap(find.byKey(runPipelineConfirmKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
@@ -123,6 +129,7 @@ void main() {
|
|||||||
'workspace': '/work/alpha',
|
'workspace': '/work/alpha',
|
||||||
'input': {'prompt': 'Review the change.'},
|
'input': {'prompt': 'Review the change.'},
|
||||||
'notify_mode': 'off',
|
'notify_mode': 'off',
|
||||||
|
'output_format': 'html',
|
||||||
});
|
});
|
||||||
expect(fields['request_key'], startsWith('app-run-1-2-'));
|
expect(fields['request_key'], startsWith('app-run-1-2-'));
|
||||||
expect('${fields['request_key']}'.length, lessThanOrEqualTo(128));
|
expect('${fields['request_key']}'.length, lessThanOrEqualTo(128));
|
||||||
@@ -317,6 +324,12 @@ void main() {
|
|||||||
// The fields stay locked while admission is unknown.
|
// The fields stay locked while admission is unknown.
|
||||||
final prompt = tester.widget<TextField>(find.byKey(runPipelinePromptKey));
|
final prompt = tester.widget<TextField>(find.byKey(runPipelinePromptKey));
|
||||||
expect(prompt.enabled, isFalse);
|
expect(prompt.enabled, isFalse);
|
||||||
|
expect(
|
||||||
|
tester.widget<DropdownButtonFormField<dynamic>>(
|
||||||
|
find.byKey(runPipelineOutputFormatKey),
|
||||||
|
).onChanged,
|
||||||
|
isNull,
|
||||||
|
);
|
||||||
|
|
||||||
await tester.tap(find.byKey(runPipelineConfirmKey));
|
await tester.tap(find.byKey(runPipelineConfirmKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|||||||
Reference in New Issue
Block a user