Merge branch 'main' into flutter/chat-composer
This commit is contained in:
@@ -79,6 +79,12 @@ class TemplateRepository {
|
|||||||
'The server returned no pipeline detail.',
|
'The server returned no pipeline detail.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
final id = detail['id'];
|
||||||
|
if (id is! num || !id.isFinite || id <= 0 || id != id.truncateToDouble()) {
|
||||||
|
throw const TemplateRepositoryException(
|
||||||
|
'The server did not confirm a created pipeline.',
|
||||||
|
);
|
||||||
|
}
|
||||||
return Map<String, dynamic>.from(detail);
|
return Map<String, dynamic>.from(detail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'template_create_wording.dart';
|
||||||
|
|
||||||
|
/// Full wrapping native label, not a clipped placeholder/floating field label.
|
||||||
|
class TemplateCreateNameField extends StatelessWidget {
|
||||||
|
const TemplateCreateNameField({
|
||||||
|
super.key,
|
||||||
|
required this.cupertino,
|
||||||
|
required this.controller,
|
||||||
|
required this.enabled,
|
||||||
|
required this.onSubmit,
|
||||||
|
});
|
||||||
|
|
||||||
|
final bool cupertino;
|
||||||
|
final TextEditingController controller;
|
||||||
|
final bool enabled;
|
||||||
|
final VoidCallback onSubmit;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => MergeSemantics(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
const Text(templateCreateNameLabel),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
if (cupertino)
|
||||||
|
CupertinoTextField(
|
||||||
|
key: templateCreateNameKey,
|
||||||
|
controller: controller,
|
||||||
|
enabled: enabled,
|
||||||
|
autofocus: true,
|
||||||
|
textInputAction: TextInputAction.done,
|
||||||
|
onSubmitted: (_) => onSubmit(),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
TextField(
|
||||||
|
key: templateCreateNameKey,
|
||||||
|
controller: controller,
|
||||||
|
enabled: enabled,
|
||||||
|
autofocus: true,
|
||||||
|
textInputAction: TextInputAction.done,
|
||||||
|
onSubmitted: (_) => onSubmit(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget templateCreateDialogAction({
|
||||||
|
required Key key,
|
||||||
|
required bool cupertino,
|
||||||
|
required VoidCallback? onPressed,
|
||||||
|
required Widget child,
|
||||||
|
bool primary = false,
|
||||||
|
}) {
|
||||||
|
if (cupertino) {
|
||||||
|
return CupertinoDialogAction(
|
||||||
|
key: key,
|
||||||
|
isDefaultAction: primary,
|
||||||
|
onPressed: onPressed,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (primary) {
|
||||||
|
return FilledButton(key: key, onPressed: onPressed, child: child);
|
||||||
|
}
|
||||||
|
return TextButton(key: key, onPressed: onPressed, child: child);
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import '../../../core/api_gateway.dart';
|
|||||||
import '../data/template_repository.dart';
|
import '../data/template_repository.dart';
|
||||||
import '../domain/template_entry.dart';
|
import '../domain/template_entry.dart';
|
||||||
import 'template_create_wording.dart';
|
import 'template_create_wording.dart';
|
||||||
|
import 'template_create_controls.dart';
|
||||||
|
|
||||||
/// Opens the native create prompt; resolves when it closes. Opening, typing and
|
/// Opens the native create prompt; resolves when it closes. Opening, typing and
|
||||||
/// Cancel send nothing; Create validates the source first and only a passing
|
/// Cancel send nothing; Create validates the source first and only a passing
|
||||||
@@ -156,7 +157,12 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
_field(),
|
TemplateCreateNameField(
|
||||||
|
cupertino: widget.cupertino,
|
||||||
|
controller: _name,
|
||||||
|
enabled: _fieldEnabled,
|
||||||
|
onSubmit: _create,
|
||||||
|
),
|
||||||
// Feedback stays next to the field it belongs to. The note below can
|
// Feedback stays next to the field it belongs to. The note below can
|
||||||
// be pushed out of the dialog's scroll viewport on a short, large-text
|
// be pushed out of the dialog's scroll viewport on a short, large-text
|
||||||
// screen; a refusal or success line must not be.
|
// screen; a refusal or success line must not be.
|
||||||
@@ -189,7 +195,8 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
final actions = [
|
final actions = [
|
||||||
_dialogAction(
|
templateCreateDialogAction(
|
||||||
|
cupertino: widget.cupertino,
|
||||||
key: templateCreateCancelKey,
|
key: templateCreateCancelKey,
|
||||||
onPressed: _sending ? null : _cancel,
|
onPressed: _sending ? null : _cancel,
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -198,7 +205,8 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
|||||||
: templateCreateCloseLabel,
|
: templateCreateCloseLabel,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
_dialogAction(
|
templateCreateDialogAction(
|
||||||
|
cupertino: widget.cupertino,
|
||||||
key: templateCreateConfirmKey,
|
key: templateCreateConfirmKey,
|
||||||
primary: true,
|
primary: true,
|
||||||
onPressed: _canSubmit ? _create : null,
|
onPressed: _canSubmit ? _create : null,
|
||||||
@@ -228,60 +236,4 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _field() {
|
|
||||||
// A wrapping label above the field, like the browser's label span: the
|
|
||||||
// Material floating label is ellipsized to `New pipeline name (requ…` at 2x
|
|
||||||
// text, and a Cupertino placeholder is not exposed as the field's name.
|
|
||||||
// Merging the visible label into the field gives both hosts one node with
|
|
||||||
// the exact wording and the field's value.
|
|
||||||
final field = widget.cupertino
|
|
||||||
? CupertinoTextField(
|
|
||||||
key: templateCreateNameKey,
|
|
||||||
controller: _name,
|
|
||||||
enabled: _fieldEnabled,
|
|
||||||
autofocus: true,
|
|
||||||
textInputAction: TextInputAction.done,
|
|
||||||
onSubmitted: (_) => _create(),
|
|
||||||
)
|
|
||||||
: TextField(
|
|
||||||
key: templateCreateNameKey,
|
|
||||||
controller: _name,
|
|
||||||
enabled: _fieldEnabled,
|
|
||||||
autofocus: true,
|
|
||||||
textInputAction: TextInputAction.done,
|
|
||||||
onSubmitted: (_) => _create(),
|
|
||||||
);
|
|
||||||
return MergeSemantics(
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [
|
|
||||||
const Text(templateCreateNameLabel),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
field,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _dialogAction({
|
|
||||||
required Key key,
|
|
||||||
required VoidCallback? onPressed,
|
|
||||||
required Widget child,
|
|
||||||
bool primary = false,
|
|
||||||
}) {
|
|
||||||
if (widget.cupertino) {
|
|
||||||
return CupertinoDialogAction(
|
|
||||||
key: key,
|
|
||||||
isDefaultAction: primary,
|
|
||||||
onPressed: onPressed,
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (primary) {
|
|
||||||
return FilledButton(key: key, onPressed: onPressed, child: child);
|
|
||||||
}
|
|
||||||
return TextButton(key: key, onPressed: onPressed, child: child);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# T1 — native create-from-template prompt
|
# T1 — native create-from-template prompt
|
||||||
|
|
||||||
|
Manager integration: retained both sides' compatible run-test gateway/scroll
|
||||||
|
repairs when merging. Split native field/action controls from dialog state so
|
||||||
|
production files remain under250lines. Added a fail-closed repository guard:
|
||||||
|
an empty/malformed created detail without a positive integral pipeline identity
|
||||||
|
cannot be reported as successful creation. The new regression failed before the
|
||||||
|
guard; all24 template tests pass after. Source/native capture recheck precedes
|
||||||
|
actual gallery/Settings delivery; no production definition was created.
|
||||||
|
|
||||||
## Result
|
## Result
|
||||||
|
|
||||||
A native Material/Cupertino prompt implements the browser's P5 create flow
|
A native Material/Cupertino prompt implements the browser's P5 create flow
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/features/templates/data/template_repository.dart';
|
||||||
|
|
||||||
|
import 'template_test_support.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test(
|
||||||
|
'a malformed created detail never becomes a claimed successful create',
|
||||||
|
() async {
|
||||||
|
for (final id in [null, 0, -1, 'unknown', 1.5]) {
|
||||||
|
final gateway = RecordingGateway([
|
||||||
|
{
|
||||||
|
'type': 'submitted',
|
||||||
|
'detail': {'id': id, 'name': 'Unconfirmed'},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
await expectLater(
|
||||||
|
TemplateRepository(gateway).submit('Topic', source),
|
||||||
|
throwsA(isA<TemplateRepositoryException>()),
|
||||||
|
);
|
||||||
|
expect(gateway.calls.single.fields['create_only'], isTrue);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user