596365d914
Render recorded artifact groups for the active host, with visit-scoped selection and an explicit selection callback. Material uses ListTile, Cupertino uses inset grouped sections with separate heading semantics. Recorded names, MIME and size are shown verbatim with honest fallbacks; nothing is resolved, fetched, previewed, downloaded or fabricated. Adds widget, host and semantics regressions plus an isolated browser probe.
195 lines
5.6 KiB
Dart
195 lines
5.6 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart';
|
|
import 'package:pipelines_app/features/artifacts/domain/artifact_record.dart';
|
|
import 'package:pipelines_app/features/artifacts/ui/artifact_visit_list.dart';
|
|
|
|
/// A fixture entry point for browser captures of [ArtifactVisitList]. It never
|
|
/// contacts a server: the groups below are recorded shapes, and the selection
|
|
/// line only echoes the widget's callback.
|
|
///
|
|
/// Query parameters:
|
|
/// platform=ios render the Cupertino host instead of Material
|
|
/// scale=1.5 large-text check
|
|
/// state=empty no recorded groups
|
|
/// state=disabled rows rendered without a selection callback
|
|
/// state=unrecorded a record with no name, url or content type
|
|
void main() {
|
|
final params = Uri.base.queryParameters;
|
|
runApp(
|
|
_ProbeApp(cupertino: params['platform'] == 'ios', state: params['state']),
|
|
);
|
|
}
|
|
|
|
ArtifactRecord _record(
|
|
String name, {
|
|
required String url,
|
|
required String contentType,
|
|
required int sizeBytes,
|
|
}) {
|
|
return ArtifactRecord.fromJson(<String, dynamic>{
|
|
'name': name,
|
|
'url': url,
|
|
'content_type': contentType,
|
|
'size_bytes': sizeBytes,
|
|
});
|
|
}
|
|
|
|
const longName =
|
|
'a-very-long-recorded-artifact-file-name-that-must-wrap-across-'
|
|
'several-lines-at-large-text-sizes.xlsx';
|
|
|
|
final List<ArtifactGroup> _groups = <ArtifactGroup>[
|
|
ArtifactGroup(
|
|
stageKey: 'build',
|
|
visit: 1,
|
|
artifacts: <ArtifactRecord>[
|
|
_record(
|
|
longName,
|
|
url: '/artifacts/7/3/$longName',
|
|
contentType:
|
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
sizeBytes: 123456,
|
|
),
|
|
],
|
|
),
|
|
ArtifactGroup(
|
|
stageKey: 'review',
|
|
visit: 1,
|
|
artifacts: <ArtifactRecord>[
|
|
_record(
|
|
'result.csv',
|
|
url: '/artifacts/7/1/result.csv',
|
|
contentType: 'text/csv',
|
|
sizeBytes: 2048,
|
|
),
|
|
_record(
|
|
'notes.md',
|
|
url: '/artifacts/7/1/notes.md',
|
|
contentType: 'text/markdown',
|
|
sizeBytes: 812,
|
|
),
|
|
],
|
|
),
|
|
ArtifactGroup(
|
|
stageKey: 'review',
|
|
visit: 2,
|
|
artifacts: <ArtifactRecord>[
|
|
_record(
|
|
'result.csv',
|
|
url: '/artifacts/7/2/result.csv',
|
|
contentType: 'text/csv',
|
|
sizeBytes: 4096,
|
|
),
|
|
],
|
|
),
|
|
];
|
|
|
|
/// Records the server sent without a name, url or content type. The list must
|
|
/// show the honest fallbacks rather than infer any of them.
|
|
final List<ArtifactGroup> _unrecordedGroups = <ArtifactGroup>[
|
|
ArtifactGroup(
|
|
stageKey: 'review',
|
|
visit: 1,
|
|
artifacts: <ArtifactRecord>[
|
|
ArtifactRecord.fromJson(const <String, dynamic>{
|
|
'name': '',
|
|
'url': '',
|
|
'content_type': '',
|
|
'size_bytes': 0,
|
|
}),
|
|
ArtifactRecord.fromJson(const <String, dynamic>{
|
|
'name': 'notes.md',
|
|
'url': '/artifacts/7/1/notes.md',
|
|
'content_type': '',
|
|
'size_bytes': 812,
|
|
}),
|
|
],
|
|
),
|
|
];
|
|
|
|
List<ArtifactGroup> _groupsFor(String? state) => switch (state) {
|
|
'empty' => const <ArtifactGroup>[],
|
|
'unrecorded' => _unrecordedGroups,
|
|
_ => _groups,
|
|
};
|
|
|
|
class _ProbeApp extends StatefulWidget {
|
|
const _ProbeApp({required this.cupertino, this.state});
|
|
|
|
final bool cupertino;
|
|
final String? state;
|
|
|
|
@override
|
|
State<_ProbeApp> createState() => _ProbeAppState();
|
|
}
|
|
|
|
class _ProbeAppState extends State<_ProbeApp> {
|
|
ArtifactGroup? _selectedGroup;
|
|
ArtifactRecord? _selectedArtifact;
|
|
|
|
String? get _selectedIdentity => _selectedGroup == null
|
|
? null
|
|
: artifactVisitIdentity(_selectedGroup!, _selectedArtifact!);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final scale =
|
|
double.tryParse(Uri.base.queryParameters['scale'] ?? '') ?? 1.0;
|
|
final selected = _selectedGroup == null
|
|
? 'Selected: none'
|
|
: 'Selected: ${_selectedGroup!.stageKey} · visit '
|
|
'${_selectedGroup!.visit} · ${_selectedArtifact!.name}';
|
|
final groups = _groupsFor(widget.state);
|
|
final selectable = widget.state != 'disabled';
|
|
final body = Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: <Widget>[
|
|
Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(16, 16, 16, 0),
|
|
child: Text('Artifact visit list probe'),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 16, 0),
|
|
child: Text(selected),
|
|
),
|
|
Expanded(
|
|
child: ArtifactVisitList(
|
|
groups: groups,
|
|
selectedIdentity: _selectedIdentity,
|
|
onSelected: selectable
|
|
? (group, artifact) => setState(() {
|
|
_selectedGroup = group;
|
|
_selectedArtifact = artifact;
|
|
})
|
|
: null,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
Widget scaled(BuildContext context, Widget? child) => MediaQuery(
|
|
data: MediaQuery.of(
|
|
context,
|
|
).copyWith(textScaler: TextScaler.linear(scale)),
|
|
child: child ?? const SizedBox.shrink(),
|
|
);
|
|
if (widget.cupertino) {
|
|
return CupertinoApp(
|
|
debugShowCheckedModeBanner: false,
|
|
builder: scaled,
|
|
home: CupertinoPageScaffold(
|
|
// Sections paint the grouped background; the page must match it or a
|
|
// white seam shows below the last section in light mode.
|
|
backgroundColor: CupertinoColors.systemGroupedBackground,
|
|
child: body,
|
|
),
|
|
);
|
|
}
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
builder: scaled,
|
|
home: Scaffold(body: body),
|
|
);
|
|
}
|
|
}
|