76 lines
2.6 KiB
Dart
76 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'runs_controller.dart';
|
|
import '../domain/run_models.dart';
|
|
|
|
class RunsList extends StatelessWidget {
|
|
const RunsList({super.key, required this.controller});
|
|
final RunsController controller;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (controller.loading && controller.runs.isEmpty) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
if (controller.error != null && controller.runs.isEmpty) {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(controller.error!),
|
|
const SizedBox(height: 8),
|
|
FilledButton(
|
|
onPressed: controller.load,
|
|
child: const Text('Retry'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
return Column(
|
|
children: [
|
|
if (controller.error != null)
|
|
MaterialBanner(
|
|
content: Text(controller.error!),
|
|
actions: [
|
|
TextButton(onPressed: controller.load, child: const Text('Retry')),
|
|
],
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: TextField(
|
|
decoration: const InputDecoration(
|
|
labelText: 'Filter runs',
|
|
prefixIcon: Icon(Icons.search),
|
|
),
|
|
onChanged: controller.setQuery,
|
|
),
|
|
),
|
|
Expanded(
|
|
child: controller.visibleRuns.isEmpty
|
|
? const Center(child: Text('No runs found.'))
|
|
: ListView.builder(
|
|
itemCount: controller.visibleRuns.length,
|
|
itemBuilder: (context, index) {
|
|
final run = controller.visibleRuns[index];
|
|
final identity = runIdentity(run['title'], run['name']);
|
|
final created =
|
|
run['created_at']?.toString() ?? 'Time unavailable';
|
|
final id = run['id'];
|
|
return ListTile(
|
|
title: Text(
|
|
identity.label.isEmpty ? 'Run $id' : identity.label,
|
|
),
|
|
subtitle: Text(
|
|
'${run['name'] ?? 'Pipeline unavailable'} · $created${run['scheduled'] == true ? ' · Scheduled' : ''}',
|
|
),
|
|
leading: Chip(label: Text(runStatusLabel(run))),
|
|
trailing: const Icon(Icons.chevron_right),
|
|
onTap: id is num ? () => controller.select(id) : null,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|