Sheets, decision options, usage, settings and artifact errors: review r2 batches H and L
Shared AppSheetHeader (title + Done) for the Runs filter/sort and Needs you sheets; Runs filter single-choice groups as check rows and statuses in sentence case; Cupertino decision options as a check list; run action sheet titled with the run; usage page without the duplicate title and with honest empty states; Settings Reconnect wording, compact notifications row and a tinted Cupertino Save workspace; friendly artifact preview failures with Retry.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
/// The viewer's words for a preview that could not be fetched.
|
||||
///
|
||||
/// The operator sees what happened in plain language and can retry; the raw
|
||||
/// exception text (`TypeError: Failed to fetch`) and bare status lines
|
||||
/// (`The server answered 404.`) never reach the screen. [status] is the HTTP
|
||||
/// status the server answered, or null when no answer arrived at all.
|
||||
String artifactPreviewFailureMessage({int? status}) {
|
||||
if (status == null) {
|
||||
return 'The preview could not be loaded. Check the connection and try '
|
||||
'again.';
|
||||
}
|
||||
if (status == 404 || status == 410) {
|
||||
return 'This file is no longer on the server.';
|
||||
}
|
||||
if (status == 401 || status == 403) {
|
||||
return 'The server did not allow this file to be opened.';
|
||||
}
|
||||
if (status >= 500) {
|
||||
return 'The server could not send this file right now.';
|
||||
}
|
||||
return 'The preview could not be loaded (status $status).';
|
||||
}
|
||||
@@ -41,8 +41,12 @@ class ArtifactViewerBody extends StatelessWidget {
|
||||
this.bytes,
|
||||
this.error,
|
||||
this.status,
|
||||
this.onRetry,
|
||||
});
|
||||
|
||||
/// Loads the current page's preview again after a failure.
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
final PagedArtifact page;
|
||||
final ArtifactPreviewPlan plan;
|
||||
final int index;
|
||||
@@ -76,6 +80,7 @@ class ArtifactViewerBody extends StatelessWidget {
|
||||
text: text,
|
||||
bytes: bytes,
|
||||
error: error,
|
||||
onRetry: onRetry,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
import '../domain/artifact_preview.dart';
|
||||
import 'artifact_html_view.dart';
|
||||
import 'artifact_table_view.dart';
|
||||
@@ -35,8 +38,12 @@ class ArtifactPreviewBody extends StatelessWidget {
|
||||
this.error,
|
||||
this.videoControllerFactory = defaultArtifactVideoController,
|
||||
this.htmlBuilder = defaultArtifactHtml,
|
||||
this.onRetry,
|
||||
});
|
||||
|
||||
/// Offered under a fetch failure; absent, the message stands alone.
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
final ArtifactPreviewPlan plan;
|
||||
final bool loading;
|
||||
final ArtifactMarkdownBuilder markdownBuilder;
|
||||
@@ -60,7 +67,7 @@ class ArtifactPreviewBody extends StatelessWidget {
|
||||
return const _Loading();
|
||||
}
|
||||
if (error != null) {
|
||||
return _Message(error!);
|
||||
return _Message(error!, onRetry: onRetry);
|
||||
}
|
||||
switch (plan.kind) {
|
||||
case ArtifactPreviewKind.image:
|
||||
@@ -201,17 +208,42 @@ class _PreviewPadding extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
const artifactPreviewRetryKey = Key('artifact-preview-retry');
|
||||
|
||||
class _Message extends StatelessWidget {
|
||||
const _Message(this.message);
|
||||
const _Message(this.message, {this.onRetry});
|
||||
|
||||
final String message;
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final retry = onRetry;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(message, textAlign: TextAlign.center),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(message, textAlign: TextAlign.center),
|
||||
if (retry != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
cupertino
|
||||
? CupertinoButton.tinted(
|
||||
key: artifactPreviewRetryKey,
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: retry,
|
||||
child: const Text('Retry'),
|
||||
)
|
||||
: FilledButton.tonal(
|
||||
key: artifactPreviewRetryKey,
|
||||
onPressed: retry,
|
||||
child: const Text('Retry'),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'artifact_selection_facts.dart';
|
||||
import '../actions/artifact_file_bridge.dart';
|
||||
import '../domain/artifact_groups.dart';
|
||||
import '../domain/artifact_preview.dart';
|
||||
import '../domain/artifact_preview_failure.dart';
|
||||
import '../domain/artifact_url.dart';
|
||||
import '../domain/gallery_navigation.dart';
|
||||
import 'artifact_external_open.dart';
|
||||
@@ -157,7 +158,7 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
if (!result.ok) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = 'The server answered ${result.status}.';
|
||||
_error = artifactPreviewFailureMessage(status: result.status);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -168,11 +169,11 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
_fetched = fetched;
|
||||
});
|
||||
},
|
||||
onError: (Object error) {
|
||||
onError: (Object _) {
|
||||
if (!mounted || generation != _generation) return;
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = 'Could not load preview: $error';
|
||||
_error = artifactPreviewFailureMessage();
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -259,6 +260,8 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
fileBridge: widget.fileBridge,
|
||||
onPrevious: () => _step(-1),
|
||||
onNext: () => _step(1),
|
||||
// A failure is never cached, so loading again fetches afresh.
|
||||
onRetry: _beginLoad,
|
||||
onOpen: plan.resolved == null ? () {} : () => _open(plan.resolved!),
|
||||
onCopy: plan.resolved == null ? () {} : () => _copy(plan.resolved!),
|
||||
);
|
||||
|
||||
@@ -67,6 +67,9 @@ const notificationRationale =
|
||||
const notificationSectionTitle = 'Notifications';
|
||||
const notificationRequestLabel = 'Enable notifications';
|
||||
|
||||
/// The compact row's visible action; [notificationRequestLabel] is its name.
|
||||
const notificationEnableShortLabel = 'Enable';
|
||||
|
||||
/// The honest wording for every state, verbatim from `web/src/notify.js`; each
|
||||
/// says plainly that the in-app `Needs you` surface is the only channel when the
|
||||
/// platform cannot notify.
|
||||
@@ -100,13 +103,21 @@ class NotificationPermissionView {
|
||||
const NotificationPermissionView({
|
||||
required this.state,
|
||||
required this.body,
|
||||
required this.headline,
|
||||
required this.helper,
|
||||
required this.canRequest,
|
||||
required this.actionLabel,
|
||||
required this.asked,
|
||||
});
|
||||
|
||||
final NotificationPermissionState state;
|
||||
|
||||
/// The browser's full sentence for the state (read out with the row).
|
||||
final String body;
|
||||
|
||||
/// The compact Settings row: a short state line and one short helper.
|
||||
final String headline;
|
||||
final String helper;
|
||||
final bool canRequest;
|
||||
final String? actionLabel;
|
||||
final bool asked;
|
||||
@@ -126,9 +137,39 @@ NotificationPermissionView notificationPermissionView(
|
||||
NotificationPermissionState.notRequested =>
|
||||
asked ? notificationDefaultAskedCopy : notificationDefaultCopy,
|
||||
};
|
||||
final (headline, helper) = switch (state) {
|
||||
NotificationPermissionState.unsupported => (
|
||||
'Not supported in this browser',
|
||||
'Runs that need you still appear in Needs you.',
|
||||
),
|
||||
NotificationPermissionState.needsSecureContext => (
|
||||
'Needs a secure page',
|
||||
'Open the app over https or localhost to turn them on.',
|
||||
),
|
||||
NotificationPermissionState.granted => (
|
||||
'Alerts are on',
|
||||
'Failed and waiting runs raise a notification.',
|
||||
),
|
||||
NotificationPermissionState.denied => (
|
||||
'Blocked by the browser',
|
||||
'Allow them in the site settings; Needs you still works.',
|
||||
),
|
||||
NotificationPermissionState.notRequested =>
|
||||
asked
|
||||
? (
|
||||
'Alerts are still off',
|
||||
'Permission was not granted. Ask again, or use Needs you.',
|
||||
)
|
||||
: (
|
||||
'Alerts are off',
|
||||
'Get told when a run fails or needs your decision.',
|
||||
),
|
||||
};
|
||||
return NotificationPermissionView(
|
||||
state: state,
|
||||
body: body,
|
||||
headline: headline,
|
||||
helper: helper,
|
||||
canRequest: canRequest,
|
||||
actionLabel: canRequest ? notificationRequestLabel : null,
|
||||
asked: asked,
|
||||
|
||||
@@ -4,7 +4,6 @@ import '../domain/attention_models.dart';
|
||||
const attentionSheetTitle = 'Needs you';
|
||||
const attentionEmptyCopy = 'Nothing needs you right now.';
|
||||
const attentionClearAllCopy = 'Clear all';
|
||||
const attentionCloseCopy = 'Close';
|
||||
|
||||
/// One row's dismissal name.
|
||||
///
|
||||
|
||||
@@ -12,6 +12,9 @@ const attentionSheetKey = ValueKey<String>('attention-sheet');
|
||||
/// The honest empty line shown when the open snapshot has no entries.
|
||||
const attentionEmptyKey = ValueKey<String>('attention-empty');
|
||||
|
||||
/// The header's Done action, which closes the sheet on both hosts.
|
||||
const attentionDoneKey = ValueKey<String>('attention-done');
|
||||
|
||||
/// The bulk dismissal action, present only while the snapshot has entries.
|
||||
const attentionClearAllKey = ValueKey<String>('attention-clear-all');
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import 'attention_status_icon.dart';
|
||||
import '../domain/attention_models.dart';
|
||||
import 'needs_you_copy.dart';
|
||||
@@ -65,25 +66,12 @@ class CupertinoNeedsYouSheet extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(20, 16, 8, 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Semantics(
|
||||
header: true,
|
||||
namesRoute: true,
|
||||
child: Text(
|
||||
attentionSheetTitle,
|
||||
style: theme.textTheme.navTitleTextStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () => _close(context),
|
||||
child: const Text(attentionCloseCopy),
|
||||
),
|
||||
],
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: AppSheetHeader(
|
||||
title: attentionSheetTitle,
|
||||
cupertino: true,
|
||||
doneKey: attentionDoneKey,
|
||||
onDone: () => _close(context),
|
||||
),
|
||||
),
|
||||
if (rows.isEmpty)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import 'attention_status_icon.dart';
|
||||
import '../domain/attention_models.dart';
|
||||
import 'needs_you_copy.dart';
|
||||
@@ -57,28 +58,18 @@ class MaterialNeedsYouSheet extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 12, 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Semantics(
|
||||
header: true,
|
||||
namesRoute: true,
|
||||
child: Text(
|
||||
attentionSheetTitle,
|
||||
style: theme.textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
AppSheetHeader(
|
||||
title: attentionSheetTitle,
|
||||
cupertino: false,
|
||||
doneKey: attentionDoneKey,
|
||||
actions: [
|
||||
if (rows.isNotEmpty)
|
||||
TextButton(
|
||||
key: attentionClearAllKey,
|
||||
onPressed: () => onClearAll(snapshot),
|
||||
child: const Text(attentionClearAllCopy),
|
||||
),
|
||||
if (rows.isNotEmpty)
|
||||
TextButton(
|
||||
key: attentionClearAllKey,
|
||||
onPressed: () => onClearAll(snapshot),
|
||||
child: const Text(attentionClearAllCopy),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
if (rows.isEmpty)
|
||||
Padding(
|
||||
|
||||
@@ -55,48 +55,68 @@ class NotificationPermissionTile extends StatelessWidget {
|
||||
final action = view.canRequest && onRequest != null
|
||||
? _action(native, view.actionLabel!, onRequest!)
|
||||
: null;
|
||||
final bodyStyle = native
|
||||
final titleStyle = native
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyLarge;
|
||||
final helperStyle = native
|
||||
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
fontSize: 15,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
// The Settings section supplies the `Notifications` heading and the page
|
||||
// inset, as for every other section, so the body starts at that edge.
|
||||
return Column(
|
||||
// One compact row: the state, one short helper line and Enable at the
|
||||
// end. The full sentence for the state is what a screen reader hears.
|
||||
// The Settings section supplies the `Notifications` heading.
|
||||
return Row(
|
||||
key: notificationTileKey,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(notificationRationale, style: bodyStyle),
|
||||
const SizedBox(height: 8),
|
||||
Semantics(
|
||||
liveRegion: true,
|
||||
child: Text(view.body, key: notificationStateKey, style: bodyStyle),
|
||||
Expanded(
|
||||
child: Semantics(
|
||||
liveRegion: true,
|
||||
label: view.body,
|
||||
excludeSemantics: true,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
view.headline,
|
||||
key: notificationStateKey,
|
||||
style: titleStyle,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(view.helper, style: helperStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// The action sits on its own row, as the browser's settings section
|
||||
// does: its label is too long to share a row at large text.
|
||||
if (action != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Align(alignment: AlignmentDirectional.centerStart, child: action),
|
||||
],
|
||||
if (action != null) ...[const SizedBox(width: 12), action],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// A short `Enable`, named in full for assistive technology.
|
||||
Widget _action(bool native, String label, VoidCallback onRequest) {
|
||||
if (native) {
|
||||
return CupertinoButton(
|
||||
key: notificationEnableKey,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onRequest,
|
||||
child: Text(label),
|
||||
);
|
||||
}
|
||||
return TextButton(
|
||||
key: notificationEnableKey,
|
||||
onPressed: onRequest,
|
||||
child: Text(label),
|
||||
const text = Text(notificationEnableShortLabel);
|
||||
final Widget button = native
|
||||
? CupertinoButton.tinted(
|
||||
key: notificationEnableKey,
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: onRequest,
|
||||
child: text,
|
||||
)
|
||||
: FilledButton.tonal(
|
||||
key: notificationEnableKey,
|
||||
onPressed: onRequest,
|
||||
child: text,
|
||||
);
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: label,
|
||||
excludeSemantics: true,
|
||||
onTap: onRequest,
|
||||
child: button,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import '../domain/run_decisions.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import 'action_refusal.dart';
|
||||
import 'decision_option_row.dart';
|
||||
import 'decision_wording.dart';
|
||||
|
||||
/// Sends the draft to the server. Returns null on success, or an
|
||||
@@ -172,39 +173,20 @@ class _DecisionPromptState extends State<_DecisionPrompt> {
|
||||
errorStyle: TextStyle(
|
||||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
),
|
||||
options: RadioGroup<String>(
|
||||
groupValue: _draft.selected,
|
||||
onChanged: (value) {
|
||||
if (value != null) _select(value);
|
||||
},
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final option in widget.decision.options)
|
||||
CupertinoButton(
|
||||
onPressed: _sending ? null : () => _select(option.key),
|
||||
child: Row(
|
||||
children: [
|
||||
CupertinoRadio<String>(
|
||||
value: option.key,
|
||||
useCheckmarkStyle: true,
|
||||
enabled: !_sending,
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(option.key),
|
||||
if (_targetText(option) case final target?)
|
||||
Text(target),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
options: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
for (final (index, option) in widget.decision.options.indexed)
|
||||
DecisionOptionRow(
|
||||
key: decisionOptionKey(option.key),
|
||||
label: option.key,
|
||||
target: _targetText(option),
|
||||
selected: _draft.selected == option.key,
|
||||
divider: index > 0,
|
||||
onTap: _sending ? null : () => _select(option.key),
|
||||
),
|
||||
],
|
||||
),
|
||||
feedback: CupertinoTextField(
|
||||
key: decisionFeedbackKey,
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
/// One option row in the Cupertino decision prompt, keyed by the option.
|
||||
ValueKey<String> decisionOptionKey(String option) =>
|
||||
ValueKey<String>('human-decision-option-$option');
|
||||
|
||||
/// One choice of the Cupertino decision prompt: a check-list row.
|
||||
///
|
||||
/// The option reads as text in the label colour, not as a blue link, with its
|
||||
/// target underneath in the secondary colour. An empty circle marks an
|
||||
/// unpicked row and a filled check circle the picked one, so the choice is
|
||||
/// visible before Confirm. The whole row is the tap target; semantics report
|
||||
/// it as a selectable member of one exclusive group. A null [onTap] (while
|
||||
/// sending) dims the row.
|
||||
class DecisionOptionRow extends StatelessWidget {
|
||||
const DecisionOptionRow({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.selected,
|
||||
required this.onTap,
|
||||
this.target,
|
||||
this.divider = false,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final String? target;
|
||||
final bool selected;
|
||||
final bool divider;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
final enabled = onTap != null;
|
||||
final labelColor = enabled
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: CupertinoColors.tertiaryLabel.resolveFrom(context);
|
||||
final mark = selected
|
||||
? Icon(
|
||||
CupertinoIcons.checkmark_circle_fill,
|
||||
color: enabled
|
||||
? theme.primaryColor
|
||||
: CupertinoColors.tertiaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Icon(
|
||||
CupertinoIcons.circle,
|
||||
color: CupertinoColors.tertiaryLabel.resolveFrom(context),
|
||||
);
|
||||
final row = Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
mark,
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
textAlign: TextAlign.start,
|
||||
style: theme.textTheme.textStyle.copyWith(
|
||||
color: labelColor,
|
||||
fontWeight: selected ? FontWeight.w600 : null,
|
||||
),
|
||||
),
|
||||
if (target case final target?)
|
||||
Text(
|
||||
target,
|
||||
textAlign: TextAlign.start,
|
||||
style: theme.textTheme.textStyle.copyWith(
|
||||
fontSize: 13,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(
|
||||
context,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return Semantics(
|
||||
inMutuallyExclusiveGroup: true,
|
||||
selected: selected,
|
||||
checked: selected,
|
||||
button: true,
|
||||
enabled: enabled,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: divider
|
||||
? Border(
|
||||
top: BorderSide(
|
||||
color: CupertinoColors.separator.resolveFrom(context),
|
||||
width: 0,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: onTap,
|
||||
child: row,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import '../actions/retry_eligibility.dart';
|
||||
import '../actions/retry_wording.dart';
|
||||
import '../actions/title_action.dart';
|
||||
import '../actions/title_wording.dart';
|
||||
import '../domain/run_models.dart' show runIdentity;
|
||||
|
||||
const runMoreMenuKey = ValueKey<String>('run-more-menu');
|
||||
|
||||
@@ -16,6 +17,13 @@ const runMoreMenuKey = ValueKey<String>('run-more-menu');
|
||||
bool showRunMoreMenu(JsonMap run) =>
|
||||
runTitleId(run) != null || canScheduleRun(run) || _canRetry(run);
|
||||
|
||||
/// The run's own name for its action sheet: its title or pipeline, else
|
||||
/// `Run <id>`, as its list row shows it.
|
||||
String runMoreMenuTitle(JsonMap run) {
|
||||
final label = runIdentity(run['title'], run['name']).label;
|
||||
return label.isEmpty ? 'Run ${run['id']}' : label;
|
||||
}
|
||||
|
||||
bool _canRetry(JsonMap run) => retryRunId(run) != null && canRetryRun(run);
|
||||
|
||||
enum _RunMoreItem { retry, rename, schedule }
|
||||
@@ -97,6 +105,8 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
|
||||
return AppOverflowMenu<_RunMoreItem>(
|
||||
key: widget.menuKey,
|
||||
cupertino: widget.cupertino,
|
||||
// The Cupertino action sheet names the run it acts on.
|
||||
sheetTitle: runMoreMenuTitle(run),
|
||||
actions: [
|
||||
for (final (item, label) in _items)
|
||||
AppMenuAction(key: _keyOf(item), value: item, label: label),
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import 'runs_controller.dart';
|
||||
|
||||
/// The Runs toolbar's choices and their labels, shared by the applied-filter
|
||||
/// chips, the filter sheet and the sort sheet. No widgets here.
|
||||
|
||||
const runSorts = [
|
||||
('newest_first', 'Newest first'),
|
||||
('oldest_first', 'Oldest first'),
|
||||
('longest_duration', 'Longest duration'),
|
||||
('shortest_duration', 'Shortest duration'),
|
||||
('pipeline_name', 'Pipeline name'),
|
||||
('status', 'Status'),
|
||||
];
|
||||
const runSchedules = [
|
||||
('any', 'Any trigger'),
|
||||
('scheduled', 'Scheduled runs'),
|
||||
('unscheduled', 'Not scheduled'),
|
||||
];
|
||||
const runTimeRanges = [
|
||||
('any_time', 'Any time'),
|
||||
('today', 'Today'),
|
||||
('last_7_days', 'Last 7 days'),
|
||||
('last_30_days', 'Last 30 days'),
|
||||
];
|
||||
|
||||
/// The pipelines the loaded runs belong to, by name then id.
|
||||
List<({int id, String name})> runFilterPipelines(RunsController controller) {
|
||||
final names = <int, String>{};
|
||||
final ids = <int>{};
|
||||
for (final run in controller.runs) {
|
||||
final id = run['pipeline_id'];
|
||||
if (id is! int) continue;
|
||||
ids.add(id);
|
||||
final name = '${run['name'] ?? ''}'.trim();
|
||||
if (name.isNotEmpty && !names.containsKey(id)) names[id] = name;
|
||||
}
|
||||
final options = ids
|
||||
.map((id) => (id: id, name: names[id] ?? 'Pipeline $id'))
|
||||
.toList();
|
||||
options.sort((a, b) {
|
||||
final nameOrder = a.name.toLowerCase().compareTo(b.name.toLowerCase());
|
||||
return nameOrder != 0 ? nameOrder : a.id.compareTo(b.id);
|
||||
});
|
||||
return options;
|
||||
}
|
||||
|
||||
/// Whether some loaded run carries no scheduling provenance at all.
|
||||
bool runsHaveUnclassified(RunsController controller) =>
|
||||
controller.runs.any((run) {
|
||||
final id = run['schedule_id'];
|
||||
return run['scheduled'] is! bool && !(id is num && id > 0);
|
||||
});
|
||||
|
||||
String runTimeRangeLabel(String value) => runTimeRanges
|
||||
.firstWhere((entry) => entry.$1 == value, orElse: () => runTimeRanges.first)
|
||||
.$2;
|
||||
String runSortLabel(String value) =>
|
||||
runSorts.firstWhere((e) => e.$1 == value, orElse: () => runSorts.first).$2;
|
||||
String runScheduleLabel(String value) => runSchedules
|
||||
.firstWhere((e) => e.$1 == value, orElse: () => runSchedules.first)
|
||||
.$2;
|
||||
@@ -0,0 +1,215 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/input/app_search_field.dart';
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import '../../pipelines/pipeline_format.dart' show runStateLabel;
|
||||
import '../domain/run_models.dart';
|
||||
import 'runs_controller.dart';
|
||||
import 'runs_filter_options.dart';
|
||||
|
||||
const runsFilterTitle = 'Filter runs';
|
||||
const runsFilterDoneKey = ValueKey<String>('runs.filter.done');
|
||||
const runsFilterClearKey = ValueKey<String>('runs.filter.clear');
|
||||
|
||||
/// The filter sheet: a header (title, Clear, Done), the text filter, then
|
||||
/// status (several may be picked), pipeline, time range and trigger (one
|
||||
/// each), every choice applied as it is picked.
|
||||
Future<void> showRunsFilterSheet(
|
||||
BuildContext context,
|
||||
RunsController controller,
|
||||
) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final sheet = _RunsFilterSheet(controller: controller, cupertino: cupertino);
|
||||
if (cupertino) {
|
||||
return showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (_) => CupertinoPopupSurface(child: SafeArea(child: sheet)),
|
||||
);
|
||||
}
|
||||
return showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
showDragHandle: true,
|
||||
useSafeArea: true,
|
||||
builder: (_) => sheet,
|
||||
);
|
||||
}
|
||||
|
||||
class _RunsFilterSheet extends StatefulWidget {
|
||||
const _RunsFilterSheet({required this.controller, required this.cupertino});
|
||||
|
||||
final RunsController controller;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
State<_RunsFilterSheet> createState() => _RunsFilterSheetState();
|
||||
}
|
||||
|
||||
class _RunsFilterSheetState extends State<_RunsFilterSheet> {
|
||||
late final TextEditingController _text = TextEditingController(
|
||||
text: widget.controller.query,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_text.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _clear() {
|
||||
_text.clear();
|
||||
widget.controller.setQuery('');
|
||||
widget.controller.clearFilters();
|
||||
}
|
||||
|
||||
Widget _section(BuildContext context, String title) {
|
||||
final style = widget.cupertino
|
||||
? CupertinoTheme.of(
|
||||
context,
|
||||
).textTheme.textStyle.copyWith(fontWeight: FontWeight.w600)
|
||||
: Theme.of(context).textTheme.titleSmall;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 4),
|
||||
child: Semantics(header: true, child: Text(title, style: style)),
|
||||
);
|
||||
}
|
||||
|
||||
/// One status: several may be on at once, so Material uses a checkbox.
|
||||
Widget _multiChoice(String label, bool checked, VoidCallback onTap) {
|
||||
if (widget.cupertino) return _checkRow(label, checked, onTap);
|
||||
return CheckboxListTile(
|
||||
dense: true,
|
||||
title: Text(label),
|
||||
value: checked,
|
||||
onChanged: (_) => onTap(),
|
||||
);
|
||||
}
|
||||
|
||||
/// One choice of a single-choice group: a check mark on the picked row.
|
||||
Widget _singleChoice(String label, bool checked, VoidCallback onTap) =>
|
||||
Semantics(
|
||||
inMutuallyExclusiveGroup: true,
|
||||
child: _checkRow(label, checked, onTap),
|
||||
);
|
||||
|
||||
Widget _checkRow(String label, bool checked, VoidCallback onTap) {
|
||||
if (widget.cupertino) {
|
||||
return CupertinoListTile(
|
||||
title: Text(label),
|
||||
trailing: checked ? const Icon(CupertinoIcons.check_mark) : null,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
return ListTile(
|
||||
dense: true,
|
||||
selected: checked,
|
||||
title: Text(label),
|
||||
trailing: checked ? const Icon(Icons.check) : null,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = widget.controller;
|
||||
final field = AppSearchField(
|
||||
fieldKey: const ValueKey('runs.filter.query'),
|
||||
controller: _text,
|
||||
cupertino: widget.cupertino,
|
||||
placeholder: 'Filter runs',
|
||||
onChanged: controller.setQuery,
|
||||
);
|
||||
return ListenableBuilder(
|
||||
listenable: controller,
|
||||
builder: (context, _) {
|
||||
final active =
|
||||
controller.activeFilterCount > 0 || controller.query.isNotEmpty;
|
||||
return ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(context).height * 0.85,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
AppSheetHeader(
|
||||
title: runsFilterTitle,
|
||||
cupertino: widget.cupertino,
|
||||
doneKey: runsFilterDoneKey,
|
||||
actions: [if (active) _clearButton()],
|
||||
),
|
||||
Flexible(child: _list(context, controller, field)),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _clearButton() => widget.cupertino
|
||||
? CupertinoButton(
|
||||
key: runsFilterClearKey,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
onPressed: _clear,
|
||||
child: const Text('Clear'),
|
||||
)
|
||||
: TextButton(
|
||||
key: runsFilterClearKey,
|
||||
onPressed: _clear,
|
||||
child: const Text('Clear'),
|
||||
);
|
||||
|
||||
Widget _list(BuildContext context, RunsController controller, Widget field) {
|
||||
return ListView(
|
||||
key: const ValueKey('runs.filter.sheet'),
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
children: [
|
||||
Padding(padding: const EdgeInsets.fromLTRB(16, 4, 16, 0), child: field),
|
||||
_section(context, 'Status'),
|
||||
for (final status in runStates)
|
||||
_multiChoice(
|
||||
runStateLabel(status),
|
||||
controller.statuses.contains(status),
|
||||
() => controller.setStatus(status),
|
||||
),
|
||||
_section(context, 'Pipeline'),
|
||||
_singleChoice(
|
||||
'Any pipeline',
|
||||
controller.pipelineId == null,
|
||||
() => controller.setPipeline(null),
|
||||
),
|
||||
for (final pipeline in runFilterPipelines(controller))
|
||||
_singleChoice(
|
||||
pipeline.name,
|
||||
controller.pipelineId == pipeline.id,
|
||||
() => controller.setPipeline(pipeline.id),
|
||||
),
|
||||
_section(context, 'Time range'),
|
||||
for (final range in runTimeRanges)
|
||||
_singleChoice(
|
||||
range.$2,
|
||||
controller.timeRange == range.$1,
|
||||
() => controller.setTimeRange(range.$1),
|
||||
),
|
||||
_section(context, 'Trigger'),
|
||||
for (final schedule in runSchedules)
|
||||
_singleChoice(
|
||||
schedule.$2,
|
||||
controller.scheduled == schedule.$1,
|
||||
() => controller.setScheduled(schedule.$1),
|
||||
),
|
||||
if (runsHaveUnclassified(controller))
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(16, 4, 16, 0),
|
||||
child: Text(
|
||||
'Some records have no scheduling provenance; they stay '
|
||||
'unclassified.',
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,17 @@
|
||||
import '../../../ui/input/app_search_field.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import '../../pipelines/pipeline_format.dart' show runStateLabel;
|
||||
import 'runs_controller.dart';
|
||||
import 'runs_filter_options.dart';
|
||||
import 'runs_filter_sheet.dart';
|
||||
|
||||
export 'runs_filter_sheet.dart' show showRunsFilterSheet;
|
||||
|
||||
const runsSortTitle = 'Sort runs';
|
||||
const runsSortDoneKey = ValueKey<String>('runs.sort.done');
|
||||
|
||||
/// The runs list's compact native filter/sort toolbar and applied-filter chips.
|
||||
///
|
||||
@@ -62,17 +69,20 @@ class RunsFilters extends StatelessWidget {
|
||||
applied.add((label: pipeline, clear: () => controller.setPipeline(null)));
|
||||
}
|
||||
for (final status in controller.statuses) {
|
||||
applied.add((label: status, clear: () => controller.setStatus(status)));
|
||||
applied.add((
|
||||
label: runStateLabel(status),
|
||||
clear: () => controller.setStatus(status),
|
||||
));
|
||||
}
|
||||
if (controller.timeRange != 'any_time') {
|
||||
applied.add((
|
||||
label: _timeRangeLabel(controller.timeRange),
|
||||
label: runTimeRangeLabel(controller.timeRange),
|
||||
clear: () => controller.setTimeRange('any_time'),
|
||||
));
|
||||
}
|
||||
if (controller.scheduled != 'any') {
|
||||
applied.add((
|
||||
label: _scheduleLabel(controller.scheduled),
|
||||
label: runScheduleLabel(controller.scheduled),
|
||||
clear: () => controller.setScheduled('any'),
|
||||
));
|
||||
}
|
||||
@@ -128,61 +138,6 @@ class RunsFilters extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
const _sorts = [
|
||||
('newest_first', 'Newest first'),
|
||||
('oldest_first', 'Oldest first'),
|
||||
('longest_duration', 'Longest duration'),
|
||||
('shortest_duration', 'Shortest duration'),
|
||||
('pipeline_name', 'Pipeline name'),
|
||||
('status', 'Status'),
|
||||
];
|
||||
const _schedules = [
|
||||
('any', 'Any trigger'),
|
||||
('scheduled', 'Scheduled runs'),
|
||||
('unscheduled', 'Not scheduled'),
|
||||
];
|
||||
const _timeRanges = [
|
||||
('any_time', 'Any time'),
|
||||
('today', 'Today'),
|
||||
('last_7_days', 'Last 7 days'),
|
||||
('last_30_days', 'Last 30 days'),
|
||||
];
|
||||
|
||||
List<({int id, String name})> _pipelines(RunsController controller) {
|
||||
final names = <int, String>{};
|
||||
final ids = <int>{};
|
||||
for (final run in controller.runs) {
|
||||
final id = run['pipeline_id'];
|
||||
if (id is! int) continue;
|
||||
ids.add(id);
|
||||
final name = '${run['name'] ?? ''}'.trim();
|
||||
if (name.isNotEmpty && !names.containsKey(id)) names[id] = name;
|
||||
}
|
||||
final options = ids
|
||||
.map((id) => (id: id, name: names[id] ?? 'Pipeline $id'))
|
||||
.toList();
|
||||
options.sort((a, b) {
|
||||
final nameOrder = a.name.toLowerCase().compareTo(b.name.toLowerCase());
|
||||
return nameOrder != 0 ? nameOrder : a.id.compareTo(b.id);
|
||||
});
|
||||
return options;
|
||||
}
|
||||
|
||||
bool _hasUnclassifiedRuns(RunsController controller) =>
|
||||
controller.runs.any((run) {
|
||||
final id = run['schedule_id'];
|
||||
return run['scheduled'] is! bool && !(id is num && id > 0);
|
||||
});
|
||||
|
||||
String _timeRangeLabel(String value) => _timeRanges
|
||||
.firstWhere((entry) => entry.$1 == value, orElse: () => _timeRanges.first)
|
||||
.$2;
|
||||
String _sortLabel(String value) =>
|
||||
_sorts.firstWhere((e) => e.$1 == value, orElse: () => _sorts.first).$2;
|
||||
String _scheduleLabel(String value) => _schedules
|
||||
.firstWhere((e) => e.$1 == value, orElse: () => _schedules.first)
|
||||
.$2;
|
||||
|
||||
/// The Runs list's app-bar actions: usage and charts, filter (with the search
|
||||
/// field inside) and sort, as icons.
|
||||
class RunsBarActions {
|
||||
@@ -252,7 +207,7 @@ class RunsBarActions {
|
||||
const ValueKey('runs.sort'),
|
||||
Icons.sort,
|
||||
CupertinoIcons.arrow_up_arrow_down,
|
||||
'Sort runs: ${_sortLabel(controller.sort)}',
|
||||
'Sort runs: ${runSortLabel(controller.sort)}',
|
||||
() => _chooseSort(context),
|
||||
),
|
||||
];
|
||||
@@ -265,10 +220,12 @@ class RunsBarActions {
|
||||
value = await showCupertinoModalPopup<String>(
|
||||
context: context,
|
||||
builder: (sheet) => CupertinoActionSheet(
|
||||
title: const Text('Sort runs'),
|
||||
title: const Text(runsSortTitle),
|
||||
actions: [
|
||||
for (final option in _sorts)
|
||||
for (final option in runSorts)
|
||||
CupertinoActionSheetAction(
|
||||
// The current order is the sheet's default (bold) action.
|
||||
isDefaultAction: controller.sort == option.$1,
|
||||
onPressed: () => Navigator.pop(sheet, option.$1),
|
||||
child: Text(
|
||||
'${controller.sort == option.$1 ? '✓ ' : ''}${option.$2}',
|
||||
@@ -286,18 +243,31 @@ class RunsBarActions {
|
||||
context: context,
|
||||
showDragHandle: true,
|
||||
builder: (sheet) => SafeArea(
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const ListTile(title: Text('Sort runs')),
|
||||
for (final option in _sorts)
|
||||
ListTile(
|
||||
title: Text(option.$2),
|
||||
trailing: controller.sort == option.$1
|
||||
? const Icon(Icons.check)
|
||||
: null,
|
||||
onTap: () => Navigator.pop(sheet, option.$1),
|
||||
const AppSheetHeader(
|
||||
title: runsSortTitle,
|
||||
cupertino: false,
|
||||
doneKey: runsSortDoneKey,
|
||||
),
|
||||
Flexible(
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
for (final option in runSorts)
|
||||
ListTile(
|
||||
selected: controller.sort == option.$1,
|
||||
title: Text(option.$2),
|
||||
trailing: controller.sort == option.$1
|
||||
? const Icon(Icons.check)
|
||||
: null,
|
||||
onTap: () => Navigator.pop(sheet, option.$1),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -306,162 +276,3 @@ class RunsBarActions {
|
||||
if (value != null && value != controller.sort) controller.setSort(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// The filter sheet: the text filter first, then status, pipeline, time range
|
||||
/// and trigger, each choice applied as it is picked.
|
||||
Future<void> showRunsFilterSheet(
|
||||
BuildContext context,
|
||||
RunsController controller,
|
||||
) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final sheet = _RunsFilterSheet(controller: controller, cupertino: cupertino);
|
||||
if (cupertino) {
|
||||
return showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (_) => CupertinoPopupSurface(child: SafeArea(child: sheet)),
|
||||
);
|
||||
}
|
||||
return showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
showDragHandle: true,
|
||||
useSafeArea: true,
|
||||
builder: (_) => sheet,
|
||||
);
|
||||
}
|
||||
|
||||
class _RunsFilterSheet extends StatefulWidget {
|
||||
const _RunsFilterSheet({required this.controller, required this.cupertino});
|
||||
|
||||
final RunsController controller;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
State<_RunsFilterSheet> createState() => _RunsFilterSheetState();
|
||||
}
|
||||
|
||||
class _RunsFilterSheetState extends State<_RunsFilterSheet> {
|
||||
late final TextEditingController _text = TextEditingController(
|
||||
text: widget.controller.query,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_text.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget _section(String title) => Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 4),
|
||||
child: Text(title, style: const TextStyle(fontWeight: FontWeight.w600)),
|
||||
);
|
||||
|
||||
Widget _choice(String label, bool checked, VoidCallback onTap) {
|
||||
if (widget.cupertino) {
|
||||
return CupertinoListTile(
|
||||
title: Text(label),
|
||||
trailing: checked ? const Icon(CupertinoIcons.check_mark) : null,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
return CheckboxListTile(
|
||||
dense: true,
|
||||
title: Text(label),
|
||||
value: checked,
|
||||
onChanged: (_) => onTap(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = widget.controller;
|
||||
final field = AppSearchField(
|
||||
fieldKey: const ValueKey('runs.filter.query'),
|
||||
controller: _text,
|
||||
cupertino: widget.cupertino,
|
||||
placeholder: 'Filter runs',
|
||||
onChanged: controller.setQuery,
|
||||
);
|
||||
return ListenableBuilder(
|
||||
listenable: controller,
|
||||
builder: (context, _) => ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(context).height * 0.85,
|
||||
),
|
||||
child: ListView(
|
||||
key: const ValueKey('runs.filter.sheet'),
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: field,
|
||||
),
|
||||
_section('Status'),
|
||||
for (final status in runStates)
|
||||
_choice(
|
||||
status,
|
||||
controller.statuses.contains(status),
|
||||
() => controller.setStatus(status),
|
||||
),
|
||||
_section('Pipeline'),
|
||||
_choice(
|
||||
'Any pipeline',
|
||||
controller.pipelineId == null,
|
||||
() => controller.setPipeline(null),
|
||||
),
|
||||
for (final pipeline in _pipelines(controller))
|
||||
_choice(
|
||||
pipeline.name,
|
||||
controller.pipelineId == pipeline.id,
|
||||
() => controller.setPipeline(pipeline.id),
|
||||
),
|
||||
_section('Time range'),
|
||||
for (final range in _timeRanges)
|
||||
_choice(
|
||||
range.$2,
|
||||
controller.timeRange == range.$1,
|
||||
() => controller.setTimeRange(range.$1),
|
||||
),
|
||||
_section('Trigger'),
|
||||
for (final schedule in _schedules)
|
||||
_choice(
|
||||
schedule.$2,
|
||||
controller.scheduled == schedule.$1,
|
||||
() => controller.setScheduled(schedule.$1),
|
||||
),
|
||||
if (_hasUnclassifiedRuns(controller))
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(16, 4, 16, 0),
|
||||
child: Text(
|
||||
'Some records have no scheduling provenance; they stay '
|
||||
'unclassified.',
|
||||
),
|
||||
),
|
||||
if (controller.activeFilterCount > 0 || controller.query.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: widget.cupertino
|
||||
? CupertinoButton(
|
||||
onPressed: () {
|
||||
_text.clear();
|
||||
controller.setQuery('');
|
||||
controller.clearFilters();
|
||||
},
|
||||
child: const Text('Clear filters'),
|
||||
)
|
||||
: TextButton(
|
||||
onPressed: () {
|
||||
_text.clear();
|
||||
controller.setQuery('');
|
||||
controller.clearFilters();
|
||||
},
|
||||
child: const Text('Clear filters'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/status/run_status_icon.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import '../../pipelines/pipeline_format.dart' show parseInstant;
|
||||
import '../../pipelines/pipeline_format.dart' show parseInstant, runStateLabel;
|
||||
import 'run_detail_content.dart';
|
||||
import 'runs_controller.dart';
|
||||
|
||||
@@ -72,10 +72,13 @@ class RunsStatsPage extends StatelessWidget {
|
||||
key: const ValueKey('runs.stats.page'),
|
||||
padding: withBarClearance(context, const EdgeInsets.all(16)),
|
||||
children: [
|
||||
Text('Usage', style: heading),
|
||||
const SizedBox(height: 8),
|
||||
// The bar already says Usage: the totals lead the page untitled.
|
||||
if (metrics.isEmpty)
|
||||
Text('No usage reported.', style: TextStyle(color: secondary))
|
||||
Text(
|
||||
'No usage has been reported for these runs.',
|
||||
key: const ValueKey('runs.stats.usage.empty'),
|
||||
style: TextStyle(color: secondary),
|
||||
)
|
||||
else
|
||||
Wrap(
|
||||
spacing: 24,
|
||||
@@ -124,11 +127,11 @@ class RunsStatsPage extends StatelessWidget {
|
||||
children: [
|
||||
RunStatusIcon(
|
||||
state: entry.key,
|
||||
label: entry.key,
|
||||
label: runStateLabel(entry.key),
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(child: Text(entry.key)),
|
||||
Expanded(child: Text(runStateLabel(entry.key))),
|
||||
Text('${entry.value}'),
|
||||
],
|
||||
),
|
||||
@@ -141,49 +144,14 @@ class RunsStatsPage extends StatelessWidget {
|
||||
const SizedBox(height: 24),
|
||||
Text('Runs in the last 7 days', style: heading),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
height: 140,
|
||||
child: Row(
|
||||
key: const ValueKey('runs.stats.days'),
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
for (final day in days)
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'${day.count}',
|
||||
style: TextStyle(color: secondary),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Flexible(
|
||||
child: FractionallySizedBox(
|
||||
heightFactor: day.count == 0
|
||||
? 0.02
|
||||
: day.count /
|
||||
days.map((d) => d.count).reduce(math.max),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(day.label, style: TextStyle(color: secondary)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (days.every((day) => day.count == 0))
|
||||
Text(
|
||||
'No runs started in the last 7 days.',
|
||||
key: const ValueKey('runs.stats.days.empty'),
|
||||
style: TextStyle(color: secondary),
|
||||
)
|
||||
else
|
||||
_DaysChart(days: days, cupertino: cupertino, secondary: secondary),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -231,3 +199,92 @@ class _PiePainter extends CustomPainter {
|
||||
@override
|
||||
bool shouldRepaint(_PiePainter oldDelegate) => true;
|
||||
}
|
||||
|
||||
/// Runs per day as bars over a baseline axis, each bar labelled with its
|
||||
/// count and its weekday underneath. Only drawn when some day has a run.
|
||||
class _DaysChart extends StatelessWidget {
|
||||
const _DaysChart({
|
||||
required this.days,
|
||||
required this.cupertino,
|
||||
required this.secondary,
|
||||
});
|
||||
|
||||
final List<({String label, int count})> days;
|
||||
final bool cupertino;
|
||||
final Color secondary;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final most = days.map((d) => d.count).reduce(math.max);
|
||||
final bar = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final axis = cupertino
|
||||
? CupertinoColors.separator.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.outlineVariant;
|
||||
return Column(
|
||||
key: const ValueKey('runs.stats.days'),
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: axis)),
|
||||
),
|
||||
child: SizedBox(
|
||||
height: 140,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
for (final day in days)
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
if (day.count > 0) ...[
|
||||
Text(
|
||||
'${day.count}',
|
||||
style: TextStyle(color: secondary),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Flexible(
|
||||
child: FractionallySizedBox(
|
||||
heightFactor: day.count / most,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: bar,
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(4),
|
||||
),
|
||||
),
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
for (final day in days)
|
||||
Expanded(
|
||||
child: Text(
|
||||
day.label,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: secondary),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,10 @@ class SettingsController extends ChangeNotifier {
|
||||
_connection.kind == transport.ConnectionKind.connecting;
|
||||
|
||||
String get primaryActionLabel => connectionActive ? 'Disconnect' : 'Connect';
|
||||
String get secondaryActionLabel => connectionActive ? 'Connect' : 'Reconnect';
|
||||
|
||||
/// Connecting again to the URL in the field; while connected that is a
|
||||
/// reconnect, so it never reads `Connect` beside `Disconnect`.
|
||||
String get secondaryActionLabel => 'Reconnect';
|
||||
|
||||
List<String> get connectionLines => connectionCardLines(
|
||||
_connection,
|
||||
|
||||
@@ -151,9 +151,12 @@ class SettingsWorkspaceSection extends StatelessWidget {
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: <Widget>[
|
||||
if (usesCupertinoControls(context))
|
||||
CupertinoButton(
|
||||
// A tinted button keeps its shape when disabled, so an
|
||||
// unsaved-nothing state reads as a disabled button,
|
||||
// not as stray grey text.
|
||||
CupertinoButton.tinted(
|
||||
key: SettingsKeys.saveWorkspace,
|
||||
padding: EdgeInsets.zero,
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: save,
|
||||
child: const Text('Save workspace'),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user