merge(app): expose native run rename in live details
This commit is contained in:
@@ -106,7 +106,12 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
child: RunsList(controller: controller, onSelected: _select),
|
||||
),
|
||||
),
|
||||
if (selected) RunDetailView(controller: controller, onBack: _back),
|
||||
if (selected)
|
||||
RunDetailView(
|
||||
controller: controller,
|
||||
gateway: widget.gateway,
|
||||
onBack: _back,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'run_detail_content.dart';
|
||||
Widget buildCupertinoRunDetail({
|
||||
required BuildContext context,
|
||||
required JsonMap run,
|
||||
required Widget titleAction,
|
||||
required bool detailLoading,
|
||||
required String? error,
|
||||
required bool copying,
|
||||
@@ -60,6 +61,13 @@ Widget buildCupertinoRunDetail({
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: titleAction,
|
||||
),
|
||||
),
|
||||
if (detailLoading) const _CupertinoNotice('Refreshing run details…'),
|
||||
if (error != null) _CupertinoNotice(error),
|
||||
if (prompt != null)
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'run_detail_content.dart';
|
||||
Widget buildMaterialRunDetail({
|
||||
required BuildContext context,
|
||||
required JsonMap run,
|
||||
required Widget titleAction,
|
||||
required bool detailLoading,
|
||||
required String? error,
|
||||
required bool copying,
|
||||
@@ -41,6 +42,7 @@ Widget buildMaterialRunDetail({
|
||||
Chip(label: Text(runStatusLabel(run))),
|
||||
Text('Run ${run['id']}'),
|
||||
Text('Pipeline ${detailPipeline(run)}'),
|
||||
titleAction,
|
||||
],
|
||||
),
|
||||
if (detailLoading) const _Notice('Refreshing run details…'),
|
||||
|
||||
@@ -2,7 +2,9 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../actions/title_action.dart';
|
||||
import 'run_detail_content.dart';
|
||||
import 'run_detail_cupertino.dart';
|
||||
import 'run_detail_material.dart';
|
||||
@@ -12,10 +14,14 @@ class RunDetailView extends StatefulWidget {
|
||||
const RunDetailView({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.gateway,
|
||||
required this.onBack,
|
||||
});
|
||||
|
||||
final RunsController controller;
|
||||
|
||||
/// The app's shared gateway; the rename action sends through it.
|
||||
final ApiGateway gateway;
|
||||
final VoidCallback onBack;
|
||||
|
||||
@override
|
||||
@@ -34,10 +40,16 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
final run = widget.controller.detail;
|
||||
if (run == null) return _placeholder(context, cupertino: cupertino);
|
||||
final prompt = detailPrompt(run);
|
||||
final titleAction = RunTitleAction(
|
||||
run: run,
|
||||
gateway: widget.gateway,
|
||||
onRunChanged: widget.controller.acceptRunDetail,
|
||||
);
|
||||
return cupertino
|
||||
? buildCupertinoRunDetail(
|
||||
context: context,
|
||||
run: run,
|
||||
titleAction: titleAction,
|
||||
detailLoading: widget.controller.detailLoading,
|
||||
error: widget.controller.error,
|
||||
copying: _copying,
|
||||
@@ -48,6 +60,7 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
: buildMaterialRunDetail(
|
||||
context: context,
|
||||
run: run,
|
||||
titleAction: titleAction,
|
||||
detailLoading: widget.controller.detailLoading,
|
||||
error: widget.controller.error,
|
||||
copying: _copying,
|
||||
|
||||
@@ -104,6 +104,27 @@ class RunsController extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Folds the server's accepted run detail into the open detail and the
|
||||
/// matching list row, mirroring the web's `applyRunTitle`.
|
||||
///
|
||||
/// A reply for a run that is no longer selected never replaces the open
|
||||
/// detail; no title or other field is invented locally.
|
||||
void acceptRunDetail(JsonMap run) {
|
||||
final id = run['id'];
|
||||
if (id == null) return;
|
||||
var changed = false;
|
||||
if (detail?['id'] == id) {
|
||||
detail = run;
|
||||
changed = true;
|
||||
}
|
||||
final index = runs.indexWhere((row) => row['id'] == id);
|
||||
if (index >= 0) {
|
||||
runs = [...runs]..[index] = {...runs[index], 'title': run['title'] ?? ''};
|
||||
changed = true;
|
||||
}
|
||||
if (changed) notifyListeners();
|
||||
}
|
||||
|
||||
void setQuery(String value) {
|
||||
query = value;
|
||||
notifyListeners();
|
||||
|
||||
Reference in New Issue
Block a user