Add labelled run entry points
Make starting runs discoverable from pipeline details and the Runs tab. Share the existing launch flow, add an active-pipeline picker, and update walkthrough guidance with focused widget coverage.
This commit is contained in:
@@ -11,10 +11,15 @@ import '../attention/notify/notification_controller.dart';
|
||||
import '../../ui/layout/content_width.dart';
|
||||
import '../attention/runtime/attention_controller.dart';
|
||||
import '../attention/runtime/attention_store.dart';
|
||||
import '../pipelines/pending_run_store.dart';
|
||||
import '../pipelines/pipeline_repository.dart';
|
||||
import '../pipelines/pipelines_controller.dart';
|
||||
import 'actions/decision_action.dart';
|
||||
import 'data/runs_repository.dart';
|
||||
import 'data/runs_sort_store.dart';
|
||||
import 'domain/run_decisions.dart';
|
||||
import 'ui/new_run_button.dart';
|
||||
import 'ui/new_run_flow.dart';
|
||||
import 'ui/run_pipeline_link.dart';
|
||||
import 'ui/run_detail_view.dart';
|
||||
import 'ui/run_search_selection.dart';
|
||||
@@ -47,6 +52,7 @@ class RunsScreen extends StatefulWidget {
|
||||
this.notifications,
|
||||
this.attention,
|
||||
this.sortStore = const SharedPreferencesRunsSortStore(),
|
||||
this.pendingRunStore = const SharedPreferencesPendingRunStore(''),
|
||||
});
|
||||
|
||||
final ApiGateway gateway;
|
||||
@@ -94,12 +100,24 @@ class RunsScreen extends StatefulWidget {
|
||||
/// Where the list's sort choice persists; tests inject a memory store.
|
||||
final RunsSortStore sortStore;
|
||||
|
||||
/// Where a New run's pending launch intent persists, under the same endpoint
|
||||
/// scope the Pipelines tab uses. Tests inject a memory store.
|
||||
final PendingRunStore pendingRunStore;
|
||||
|
||||
@override
|
||||
State<RunsScreen> createState() => _RunsScreenState();
|
||||
}
|
||||
|
||||
/// The vertical band the New run button occupies over the list's bottom edge:
|
||||
/// its margin, the extended button's height and its margin again.
|
||||
const double _newRunBand = 88;
|
||||
|
||||
class _RunsScreenState extends State<RunsScreen> {
|
||||
late final RunsController controller;
|
||||
|
||||
/// Starts a run from the New run picker. Its state is only the pending
|
||||
/// launch intent; the pipeline itself is read when the operator picks one.
|
||||
late final PipelinesController _launches;
|
||||
num? _shownRunId;
|
||||
int? _reportedPipelineId;
|
||||
bool _applyingRoutePipeline = false;
|
||||
@@ -118,6 +136,10 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
RunsRepository(widget.gateway),
|
||||
sortStore: widget.sortStore,
|
||||
);
|
||||
_launches = PipelinesController(
|
||||
PipelinesRepository(widget.gateway),
|
||||
pendingRunStore: widget.pendingRunStore,
|
||||
);
|
||||
// A deleted open run closes its detail; the route returns to the list.
|
||||
controller.onOpenRunRemoved = () =>
|
||||
widget.onBack?.call(controller.pipelineId);
|
||||
@@ -234,6 +256,23 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
widget.onBack?.call(controller.pipelineId);
|
||||
}
|
||||
|
||||
/// The New run picker, then the same start flow a pipeline's Run opens.
|
||||
void _startNewRun() => unawaited(
|
||||
startNewRunFlow(
|
||||
context: context,
|
||||
controller: _launches,
|
||||
gateway: widget.gateway,
|
||||
onRunStarted: _newRunStarted,
|
||||
),
|
||||
);
|
||||
|
||||
/// An accepted launch re-reads the list so its row appears, then opens the
|
||||
/// run the same way a row tap does.
|
||||
void _newRunStarted(int id) {
|
||||
unawaited(controller.resync());
|
||||
_select(id);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.removeListener(_selectionChanged);
|
||||
@@ -241,6 +280,7 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
controller.removeListener(_detailChanged);
|
||||
_page.dispose();
|
||||
controller.dispose();
|
||||
_launches.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -285,20 +325,55 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
onClosed: _back,
|
||||
builder: (context) => _detail(() => Navigator.of(context).maybePop()),
|
||||
);
|
||||
final list = AnimatedBuilder(
|
||||
animation: controller,
|
||||
builder: (context, _) => ContentWidth(
|
||||
child: RunsList(
|
||||
active: narrow ? !selected : true,
|
||||
controller: controller,
|
||||
onSelected: _select,
|
||||
syncToken: widget.syncToken,
|
||||
attentionStore: widget.attentionStore,
|
||||
attentionNow: widget.attentionNow,
|
||||
notifications: widget.notifications,
|
||||
attention: widget.attention,
|
||||
// The New run button floats over the list's bottom-right corner while the
|
||||
// list is the visible view. The list reserves the button's band in its
|
||||
// bottom padding, so its last row rests above the button, and the overlay
|
||||
// lifts clear of the shell's bar like the list's own clearance does.
|
||||
final list = Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
AnimatedBuilder(
|
||||
animation: controller,
|
||||
builder: (context, _) {
|
||||
final showsButton = !(narrow && selected);
|
||||
final media = MediaQuery.of(context);
|
||||
return MediaQuery(
|
||||
data: media.copyWith(
|
||||
padding: media.padding.copyWith(
|
||||
bottom:
|
||||
media.padding.bottom + (showsButton ? _newRunBand : 0),
|
||||
),
|
||||
),
|
||||
child: ContentWidth(
|
||||
child: RunsList(
|
||||
active: narrow ? !selected : true,
|
||||
controller: controller,
|
||||
onSelected: _select,
|
||||
syncToken: widget.syncToken,
|
||||
attentionStore: widget.attentionStore,
|
||||
attentionNow: widget.attentionNow,
|
||||
notifications: widget.notifications,
|
||||
attention: widget.attention,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
AnimatedBuilder(
|
||||
animation: controller,
|
||||
builder: (context, _) => narrow && selected
|
||||
? const SizedBox.shrink()
|
||||
: Positioned(
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: 16 + MediaQuery.paddingOf(context).bottom,
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.bottomEnd,
|
||||
child: NewRunButton(onPressed: _startNewRun),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
if (narrow) return list;
|
||||
return ListDetailPanes(
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// The Runs tab's New run action: an extended floating button that opens the
|
||||
/// pipeline picker. It is labelled, so it needs no tooltip of its own.
|
||||
class NewRunButton extends StatelessWidget {
|
||||
const NewRunButton({super.key, required this.onPressed});
|
||||
|
||||
final VoidCallback onPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => FloatingActionButton.extended(
|
||||
key: const Key('runs-new-run'),
|
||||
onPressed: onPressed,
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('New run'),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../pipelines/pipeline_models.dart';
|
||||
import '../../pipelines/pipeline_repository.dart';
|
||||
import '../../pipelines/pipelines_controller.dart';
|
||||
import '../../pipelines/ui/run_pipeline_flow.dart';
|
||||
import '../../pipelines/ui/run_pipeline_wording.dart';
|
||||
import 'new_run_picker.dart';
|
||||
|
||||
/// The Runs tab's New run: pick an active pipeline, read its latest version,
|
||||
/// then the same start flow a pipeline's Run action opens.
|
||||
Future<void> startNewRunFlow({
|
||||
required BuildContext context,
|
||||
required PipelinesController controller,
|
||||
required ApiGateway gateway,
|
||||
ValueChanged<int>? onRunStarted,
|
||||
}) async {
|
||||
final repository = PipelinesRepository(gateway);
|
||||
final pipelineId = await pickPipelineForNewRun(context, repository);
|
||||
if (pipelineId == null || !context.mounted) return;
|
||||
final PipelineDetail detail;
|
||||
try {
|
||||
detail = await repository.getPipeline(pipelineId, 0);
|
||||
} catch (error) {
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.maybeOf(
|
||||
context,
|
||||
)?.showSnackBar(SnackBar(content: Text(describeRunPipelineError(error))));
|
||||
return;
|
||||
}
|
||||
if (!context.mounted) return;
|
||||
await openRunPipelineFlow(
|
||||
context: context,
|
||||
controller: controller,
|
||||
detail: detail,
|
||||
gateway: gateway,
|
||||
onRunStarted: onRunStarted,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../pipelines/pipeline_models.dart';
|
||||
import '../../pipelines/pipeline_repository.dart';
|
||||
import '../../pipelines/ui/run_pipeline_wording.dart';
|
||||
|
||||
/// Whether an active pipeline matches a picker search by name. An empty query
|
||||
/// matches every pipeline.
|
||||
bool pipelineMatchesQuery(PipelineSummary pipeline, String query) {
|
||||
final needle = query.trim().toLowerCase();
|
||||
if (needle.isEmpty) return true;
|
||||
return pipeline.displayName.toLowerCase().contains(needle);
|
||||
}
|
||||
|
||||
/// Opens the searchable list of active pipelines. Resolves to the chosen
|
||||
/// pipeline's id, or null when the picker is dismissed.
|
||||
Future<int?> pickPipelineForNewRun(
|
||||
BuildContext context,
|
||||
PipelinesRepository repository,
|
||||
) => showDialog<int>(
|
||||
context: context,
|
||||
builder: (_) => _PipelinePicker(repository: repository),
|
||||
);
|
||||
|
||||
class _PipelinePicker extends StatefulWidget {
|
||||
const _PipelinePicker({required this.repository});
|
||||
|
||||
final PipelinesRepository repository;
|
||||
|
||||
@override
|
||||
State<_PipelinePicker> createState() => _PipelinePickerState();
|
||||
}
|
||||
|
||||
class _PipelinePickerState extends State<_PipelinePicker> {
|
||||
late Future<List<PipelineSummary>> _pipelines = _loadActive();
|
||||
String _query = '';
|
||||
|
||||
/// Archived pipelines cannot run, so the picker offers only active ones.
|
||||
Future<List<PipelineSummary>> _loadActive() async {
|
||||
final all = await widget.repository.listPipelines();
|
||||
return all.where((pipeline) => !pipeline.archived).toList(growable: false);
|
||||
}
|
||||
|
||||
void _retry() => setState(() => _pipelines = _loadActive());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Dialog(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 480, maxHeight: 560),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text('Choose a pipeline', style: theme.textTheme.titleLarge),
|
||||
const Padding(padding: EdgeInsets.only(top: 12)),
|
||||
TextField(
|
||||
key: const Key('new-run-search'),
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Search pipelines',
|
||||
prefixIcon: Icon(Icons.search),
|
||||
),
|
||||
onChanged: (value) => setState(() => _query = value),
|
||||
),
|
||||
const Padding(padding: EdgeInsets.only(top: 8)),
|
||||
Flexible(child: _body(context)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _body(BuildContext context) {
|
||||
return FutureBuilder<List<PipelineSummary>>(
|
||||
future: _pipelines,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(24),
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
if (snapshot.hasError) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
describeRunPipelineError(snapshot.error!),
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
TextButton(onPressed: _retry, child: const Text('Retry')),
|
||||
],
|
||||
);
|
||||
}
|
||||
final active = snapshot.data ?? const <PipelineSummary>[];
|
||||
if (active.isEmpty) {
|
||||
return const _Notice('No active pipelines.');
|
||||
}
|
||||
final matches = active
|
||||
.where((pipeline) => pipelineMatchesQuery(pipeline, _query))
|
||||
.toList(growable: false);
|
||||
if (matches.isEmpty) {
|
||||
return const _Notice('No pipeline matches the search.');
|
||||
}
|
||||
return ListView(
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
for (final pipeline in matches)
|
||||
ListTile(
|
||||
key: ValueKey<String>('new-run-pipeline-${pipeline.id}'),
|
||||
title: Text(
|
||||
pipeline.displayName,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
subtitle: Text(
|
||||
'v${pipeline.version} · ${pipeline.stages} stages',
|
||||
),
|
||||
onTap: () => Navigator.of(context).pop(pipeline.id),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Notice extends StatelessWidget {
|
||||
const _Notice(this.message);
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(message, style: TextStyle(color: Theme.of(context).hintColor)),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user