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:
@@ -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