Files
pipelines/app/lib/features/settings/storage/storage_usage.dart
T
alan 545291e04a App: run failure reasons, Run again, labelled tabs, actionable errors, nav fixes
- Run rows show a failed run's reason (else its diagnostic's first line,
  full text in a tooltip) or a short result preview; the Summary leads
  with "Why it failed".
- Run again for succeeded/canceled/interrupted runs opens the New run form
  pre-filled (prompt, workspace, report format) at the latest version with
  the original offered.
- Run detail and stage tabs show their names; touch shows captions on the
  Runs header and artifact viewer actions (desktop keeps tooltips).
- ErrorNotice maps not connected / server too old / permission / timeout
  to what to do, raw detail behind Details (Schedules, create chat, Runs,
  Pipelines banners).
- Settings has no Back arrow; Schedules keeps the rail on wide windows;
  phone Settings leads with Connection and Notifications and has a
  Jump to topic menu.
- Walkthrough: Open Connection (skipped when connected), labelled Copy.
- Pluralised counts; no duplicate status/rail names for screen readers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 20:16:22 +00:00

74 lines
2.8 KiB
Dart

import 'package:flutter/material.dart';
import '../settings_group.dart';
import 'storage_controls.dart';
import 'storage_models.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/text/plural.dart';
class StorageUsage extends StatelessWidget {
const StorageUsage({super.key, required this.data});
final JsonMap data;
@override
Widget build(BuildContext context) => SettingsGroup(
title: 'Server storage',
footer: const Text(
'Combined file sizes on the connected server, with shared files counted once. Protected data may prevent reaching a size limit.',
),
children: [
storagePadding(
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'${data['partial'] == true ? 'At least ' : ''}${storageBytes(storageInt(data['total_bytes']))} used',
style: DefaultTextStyle.of(
context,
).style.copyWith(fontWeight: FontWeight.bold),
),
if (_measured(context) case final String measured)
Text('Measured $measured'),
if (data['partial'] == true)
const Text('Measurement is incomplete. See details below.'),
],
),
),
for (final category in storageRows(data['categories']))
storagePadding(
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Wrap(
alignment: WrapAlignment.spaceBetween,
spacing: 16,
children: [
Text('${category['label'] ?? category['id']}'),
Text(
'${category['partial'] == true ? 'At least ' : ''}${storageBytes(storageInt(category['bytes']))}',
),
],
),
Text(countLabel(storageInt(category['files']), 'file')),
if (category['path'] case final String path when path.isNotEmpty)
Text(path, softWrap: true),
if (category['error'] case final String error
when error.isNotEmpty)
Text(error),
],
),
),
if (data['warnings'] case final List warnings when warnings.isNotEmpty)
storagePadding(Text(warnings.join('\n'))),
],
);
String? _measured(BuildContext context) {
final time = DateTime.tryParse('${data['measured_at'] ?? ''}')?.toLocal();
if (time == null) return null;
final material = Localizations.of<MaterialLocalizations>(
context,
MaterialLocalizations,
);
if (material == null) return null;
return '${time.day} ${material.formatMonthYear(time)} · ${material.formatTimeOfDay(TimeOfDay.fromDateTime(time), alwaysUse24HourFormat: true)}';
}
}