Complete chat file previews downloads and explorer actions
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/chat/files/files_urls.dart';
|
||||
|
||||
/// A static, two-level explorer fixture. Its files live in capture/fixtures/files.
|
||||
JsonMap probeFilesReply(JsonMap request) {
|
||||
final fields = request['list_directory'] as Map?;
|
||||
final path = '${fields?['path'] ?? '/srv/probe/release'}';
|
||||
final nested = path.endsWith('/assets');
|
||||
final entries = nested
|
||||
? <(String, int)>[('design.png', 18432), ('icon.jpg', 23000)]
|
||||
: <(String, int)>[
|
||||
('design.png', 18432),
|
||||
('icon.jpg', 23000),
|
||||
('release.md', 640),
|
||||
('config.json', 220),
|
||||
('metrics.csv', 88),
|
||||
('report.pdf', 45000),
|
||||
('archive.zip', 85000),
|
||||
('server.log', 12582912),
|
||||
('demo.mp4', 8000000),
|
||||
];
|
||||
return {
|
||||
'id': request['id'],
|
||||
'type': 'directory_listing',
|
||||
'directory_listing': {
|
||||
'path': path,
|
||||
'home': '/workspace',
|
||||
'parent': nested
|
||||
? path.substring(0, path.lastIndexOf('/'))
|
||||
: '/workspace',
|
||||
'entries': [
|
||||
if (!nested) ...[
|
||||
{'name': 'assets', 'path': '$path/assets', 'is_dir': true},
|
||||
{
|
||||
'name': '.config',
|
||||
'path': '$path/.config',
|
||||
'is_dir': true,
|
||||
'hidden': true,
|
||||
},
|
||||
],
|
||||
for (final (name, size) in entries)
|
||||
{
|
||||
'name': name,
|
||||
'path': '$path/$name',
|
||||
'is_dir': false,
|
||||
'size': size,
|
||||
'modified': '2026-11-07T00:00:00Z',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
void installFilesFixture() {
|
||||
resolveFileUrls = (_, path) {
|
||||
final name = Uri.encodeComponent(path.split('/').last);
|
||||
final view = Uri.base.resolve('/capture-files/$name');
|
||||
return FileUrls(
|
||||
view: view,
|
||||
download: view.replace(queryParameters: {'download': '1'}),
|
||||
);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user