Files
pipelines/app/lib/features/pipelines/widgets/pipeline_summary_view.dart
T
alan d1b05217c9 Remove Cupertino pipeline branches
Keep the pipeline feature on its existing Material path because the app runs under MaterialApp and never selects Cupertino hosts. Preserve public cupertino parameters and required Cupertino icon values for later cleanup and shared controls.
2026-11-11 04:53:12 +00:00

155 lines
5.3 KiB
Dart

import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/layout/app_list_row.dart';
import '../../../ui/layout/facts_grid.dart';
import '../../../ui/layout/section_heading.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_definition_validation.dart';
import 'pipeline_detail_styles.dart';
/// The Summary's facts grid.
const pipelineSummaryFactsKey = Key('pipeline-summary-facts');
/// Summary tab: the recorded facts as a compact grid, the pipeline's saved
/// schedules and the version history, flat on the page on both hosts (the
/// same structure as the run Summary). Version rows are the app's shared list
/// row; the shown version is the selected row, 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,
this.showIdentity = true,
});
final PipelinesController controller;
final PipelineDetail detail;
final ApiGateway gateway;
/// Whether to start with the recorded identity line (`id · version ·
/// stages`). False when the top bar's title pill already carries it.
final bool showIdentity;
@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.
if (showIdentity)
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),
),
),
PipelineDefinitionValidation(gateway: gateway, source: detail.source),
_fields(context),
SchedulePipelineSection(
gateway: gateway,
pipelineId: detail.id,
version: detail.resolvedVersion,
),
_versions(context),
],
);
}
/// Only recorded values are facts: a blank one is omitted, not drawn empty.
Widget _fields(BuildContext context) {
final fields = [
for (final field in pipelineSummaryFields(detail))
if (field.value.trim().isNotEmpty) field,
];
if (fields.isEmpty) return const SizedBox.shrink();
return FactsGrid(
key: pipelineSummaryFactsKey,
cupertino: false,
items: [
for (final field in fields)
FactsGridItem(
key: ValueKey('pipeline-summary-${_slug(field.key)}'),
label: field.key,
value: field.value,
// A hash gets its own line; the host font is kept (the pipeline
// detail does not switch identifiers to monospace).
wide: field.monospace,
),
],
);
}
Widget _versions(BuildContext context) {
final effective = detail.resolvedVersion;
final showingLatest = effective == detail.latestVersion;
final versions = detail.versions;
final rows = <Widget>[
if (!showingLatest)
AppListRow(
key: const Key('pipeline-latest-version'),
cupertino: false,
title: Text('View latest v${detail.latestVersion}'),
subtitle: const Text('Return to the latest version'),
divider: versions.isNotEmpty,
onTap: () => controller.selectVersion(0),
),
for (var index = 0; index < versions.length; index += 1)
AppListRow(
key: Key('pipeline-version-${versions[index].version}'),
cupertino: false,
selected: versions[index].version == effective,
title: Text('v${versions[index].version}'),
time: formatLocalTimestamp(versions[index].createdAt),
subtitle: Text(
[
stageCountText(versions[index].stages),
if (versions[index].version == detail.latestVersion) 'latest',
].join(' · '),
),
divider: index < versions.length - 1,
onTap: () => controller.selectVersion(versions[index].version),
),
if (versions.isEmpty)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Text(
'No versions recorded.',
style: pipelineMutedStyle(context),
),
),
];
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SectionHeading(
title: 'Versions',
header: true,
padding: EdgeInsetsDirectional.only(start: 16, end: 8),
),
...rows,
],
);
}
}
String _slug(String label) => label.toLowerCase().replaceAll(' ', '-');