69ae0519bd
Keep capture and probe tooling on the app's single Material surface by removing obsolete platform switches, hosts, and documentation. Preserve the existing Material routes and fixture behavior while retaining compatibility APIs outside this lane.
180 lines
5.0 KiB
Dart
180 lines
5.0 KiB
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:
|
|
/// 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(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({this.state});
|
|
|
|
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(),
|
|
);
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
builder: scaled,
|
|
home: Scaffold(body: body),
|
|
);
|
|
}
|
|
}
|