78e9d03759
Compact list toolbar and rows on the web's 12px inset, a title line with the trailing version, one muted facts line plus the last-run line, and row separators. The detail header becomes one identity line; its recorded id/version/stage facts move to the top of Summary, where web renders detail-subtitle.
170 lines
5.1 KiB
Dart
170 lines
5.1 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../../schedules/ui/pipeline/schedule_pipeline_section.dart';
|
|
import '../pipeline_format.dart';
|
|
import '../pipeline_models.dart';
|
|
import '../pipeline_query.dart';
|
|
import '../pipelines_controller.dart';
|
|
import 'pipeline_controls.dart';
|
|
import 'pipeline_detail_styles.dart';
|
|
|
|
/// Summary tab: key/value facts, the pipeline's saved schedules and the version
|
|
/// history. Version rows are selectable; the latest version's row is marked and
|
|
/// a historical selection offers an explicit return to latest.
|
|
class PipelineSummaryView extends StatelessWidget {
|
|
const PipelineSummaryView({
|
|
super.key,
|
|
required this.controller,
|
|
required this.detail,
|
|
required this.gateway,
|
|
});
|
|
|
|
final PipelinesController controller;
|
|
final PipelineDetail detail;
|
|
final ApiGateway gateway;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final historical = detail.resolvedVersion != detail.latestVersion;
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
// The web's Summary subtitle: the compact header names the pipeline,
|
|
// this line carries its recorded identity.
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
|
child: Text(
|
|
pipelineSubtitle(detail),
|
|
style: pipelineMutedStyle(context),
|
|
),
|
|
),
|
|
if (historical)
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
|
child: Text(
|
|
'Viewing v${detail.resolvedVersion} '
|
|
'(latest v${detail.latestVersion}).',
|
|
style: pipelineMutedStyle(context),
|
|
),
|
|
),
|
|
_fields(context),
|
|
SchedulePipelineSection(
|
|
gateway: gateway,
|
|
pipelineId: detail.id,
|
|
version: detail.resolvedVersion,
|
|
),
|
|
_versions(context),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _fields(BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
for (final field in pipelineSummaryFields(detail))
|
|
Padding(
|
|
padding: const EdgeInsets.only(bottom: 12),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(field.key, style: pipelineMutedStyle(context)),
|
|
SelectableText(
|
|
field.value,
|
|
style: pipelineValueStyle(
|
|
context,
|
|
monospace: field.monospace,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _versions(BuildContext context) {
|
|
final effective = detail.resolvedVersion;
|
|
final showingLatest = effective == detail.latestVersion;
|
|
final rows = <Widget>[
|
|
if (!showingLatest)
|
|
_versionTile(
|
|
context,
|
|
key: const Key('pipeline-latest-version'),
|
|
subtitle: 'Return to the latest version',
|
|
selected: false,
|
|
label: 'View latest v${detail.latestVersion}',
|
|
onTap: () => controller.selectVersion(0),
|
|
),
|
|
for (final version in detail.versions)
|
|
_versionTile(
|
|
context,
|
|
key: Key('pipeline-version-${version.version}'),
|
|
subtitle: [
|
|
stageCountText(version.stages),
|
|
?formatLocalTimestamp(version.createdAt),
|
|
].join(' · '),
|
|
selected: version.version == effective,
|
|
label: 'v${version.version}',
|
|
onTap: () => controller.selectVersion(version.version),
|
|
),
|
|
if (detail.versions.isEmpty)
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: Text(
|
|
'No versions recorded.',
|
|
style: pipelineMutedStyle(context),
|
|
),
|
|
),
|
|
];
|
|
if (useCupertinoControls(context)) {
|
|
return CupertinoListSection.insetGrouped(
|
|
header: const Text('VERSIONS'),
|
|
children: rows,
|
|
);
|
|
}
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
|
|
child: Text('Versions', style: pipelineSectionStyle(context)),
|
|
),
|
|
...rows,
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _versionTile(
|
|
BuildContext context, {
|
|
required Key key,
|
|
required String subtitle,
|
|
required bool selected,
|
|
required String label,
|
|
required VoidCallback onTap,
|
|
}) {
|
|
if (useCupertinoControls(context)) {
|
|
return CupertinoListTile(
|
|
key: key,
|
|
title: Text(label),
|
|
subtitle: Text(subtitle),
|
|
trailing: selected ? const Icon(CupertinoIcons.check_mark) : null,
|
|
onTap: onTap,
|
|
);
|
|
}
|
|
return ListTile(
|
|
key: key,
|
|
selected: selected,
|
|
title: Text(label),
|
|
subtitle: Text(subtitle),
|
|
trailing: selected ? const Icon(Icons.check) : null,
|
|
onTap: onTap,
|
|
);
|
|
}
|
|
}
|