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'),
|
||||
)
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../adaptive/host.dart';
|
||||
|
||||
/// The label of every sheet's close action.
|
||||
const appSheetDoneLabel = 'Done';
|
||||
|
||||
/// The app's one sheet header: the sheet's [title] at the start, then any
|
||||
/// extra [actions] (Clear all), then Done, which closes the sheet.
|
||||
///
|
||||
/// Material shows the title in `titleLarge` and a [TextButton]; Cupertino
|
||||
/// shows the navigation title style and a bold [CupertinoButton], like a
|
||||
/// modal's navigation bar. The title is a header that names the route, so a
|
||||
/// screen reader announces the sheet by it. Nothing has a fixed height and the
|
||||
/// title wraps at large text. Used by the Runs filter and sort sheets and the
|
||||
/// Needs you sheet, so every sheet closes the same way, not only by its drag
|
||||
/// handle.
|
||||
class AppSheetHeader extends StatelessWidget {
|
||||
const AppSheetHeader({
|
||||
super.key,
|
||||
required this.title,
|
||||
this.actions = const [],
|
||||
this.onDone,
|
||||
this.doneKey,
|
||||
this.cupertino,
|
||||
});
|
||||
|
||||
final String title;
|
||||
|
||||
/// Controls before Done, in the host's style.
|
||||
final List<Widget> actions;
|
||||
|
||||
/// Closes the sheet; the default pops the route the header is in.
|
||||
final VoidCallback? onDone;
|
||||
final Key? doneKey;
|
||||
|
||||
/// Overrides the host detection.
|
||||
final bool? cupertino;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = this.cupertino ?? usesCupertinoHost(context);
|
||||
final done = onDone ?? () => Navigator.of(context).maybePop();
|
||||
final titleStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
|
||||
: Theme.of(context).textTheme.titleLarge;
|
||||
final Widget doneButton = cupertino
|
||||
? CupertinoButton(
|
||||
key: doneKey,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||
onPressed: done,
|
||||
child: const Text(
|
||||
appSheetDoneLabel,
|
||||
style: TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
)
|
||||
: TextButton(
|
||||
key: doneKey,
|
||||
onPressed: done,
|
||||
child: const Text(appSheetDoneLabel),
|
||||
);
|
||||
return Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
cupertino ? 20 : 24,
|
||||
cupertino ? 8 : 0,
|
||||
8,
|
||||
4,
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final heading = Expanded(
|
||||
child: Semantics(
|
||||
header: true,
|
||||
namesRoute: true,
|
||||
child: Text(title, style: titleStyle),
|
||||
),
|
||||
);
|
||||
// A narrow sheet at large text moves the extra actions to a line
|
||||
// of their own under the title, so nothing is squeezed off.
|
||||
final narrow =
|
||||
constraints.maxWidth <
|
||||
MediaQuery.textScalerOf(context).scale(_wideHeaderWidth);
|
||||
if (actions.isEmpty || !narrow) {
|
||||
return Row(children: [heading, ...actions, doneButton]);
|
||||
}
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(children: [heading, doneButton]),
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Wrap(children: actions),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Below this width (scaled with the text) the extra actions wrap under the
|
||||
/// title.
|
||||
const double _wideHeaderWidth = 360;
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/artifacts/domain/artifact_preview_failure.dart';
|
||||
|
||||
void main() {
|
||||
test('fetch failures read as plain language, never raw errors', () {
|
||||
expect(
|
||||
artifactPreviewFailureMessage(),
|
||||
'The preview could not be loaded. Check the connection and try again.',
|
||||
);
|
||||
expect(
|
||||
artifactPreviewFailureMessage(status: 404),
|
||||
'This file is no longer on the server.',
|
||||
);
|
||||
expect(
|
||||
artifactPreviewFailureMessage(status: 403),
|
||||
'The server did not allow this file to be opened.',
|
||||
);
|
||||
expect(
|
||||
artifactPreviewFailureMessage(status: 502),
|
||||
'The server could not send this file right now.',
|
||||
);
|
||||
expect(
|
||||
artifactPreviewFailureMessage(status: 418),
|
||||
'The preview could not be loaded (status 418).',
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -12,6 +12,8 @@ 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_external_open.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_gallery_page.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_content.dart'
|
||||
show artifactPreviewRetryKey;
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_fetch.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_page.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_visit_list.dart';
|
||||
@@ -464,8 +466,39 @@ void main() {
|
||||
|
||||
pending.complete(ArtifactFetchResult(status: 404, bytes: Uint8List(0)));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('The server answered 404.'), findsOneWidget);
|
||||
expect(find.text('This file is no longer on the server.'), findsOneWidget);
|
||||
expect(find.textContaining('answered'), findsNothing);
|
||||
expect(find.byType(SelectableText), findsNothing);
|
||||
expect(find.byKey(artifactPreviewRetryKey), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Retry fetches a failed preview again', (tester) async {
|
||||
final text = recordedArtifact(
|
||||
'notes.txt',
|
||||
url: '/artifacts/1/1/notes.txt',
|
||||
contentType: 'text/plain',
|
||||
);
|
||||
final group = _group([text]);
|
||||
var calls = 0;
|
||||
await _pumpViewer(
|
||||
tester,
|
||||
groups: [group],
|
||||
selected: artifactVisitIdentity(group, text),
|
||||
fetch: (_) async {
|
||||
calls++;
|
||||
if (calls == 1) throw const ArtifactFetchException('network down');
|
||||
return ArtifactFetchResult(
|
||||
status: 200,
|
||||
bytes: Uint8List.fromList('hello'.codeUnits),
|
||||
);
|
||||
},
|
||||
);
|
||||
expect(find.byKey(artifactPreviewRetryKey), findsOneWidget);
|
||||
await tester.tap(find.byKey(artifactPreviewRetryKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(calls, 2);
|
||||
expect(find.byKey(artifactPreviewRetryKey), findsNothing);
|
||||
expect(find.text('hello'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('a network failure is reported instead of an empty preview', (
|
||||
@@ -483,8 +516,15 @@ void main() {
|
||||
selected: artifactVisitIdentity(group, text),
|
||||
fetch: (_) async => throw const ArtifactFetchException('network down'),
|
||||
);
|
||||
expect(find.textContaining('Could not load preview'), findsOneWidget);
|
||||
expect(find.textContaining('network down'), findsOneWidget);
|
||||
// A friendly line with Retry, never the raw exception text.
|
||||
expect(
|
||||
find.text(
|
||||
'The preview could not be loaded. Check the connection and try again.',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.textContaining('network down'), findsNothing);
|
||||
expect(find.byKey(artifactPreviewRetryKey), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino draws the same text preview and controls', (
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:pipelines_app/features/attention/notify/notification_controller.
|
||||
import 'package:pipelines_app/features/attention/notify/notification_models.dart';
|
||||
import 'package:pipelines_app/features/attention/notify/notification_store.dart';
|
||||
import 'package:pipelines_app/features/attention/ui/needs_you_runs_heading.dart';
|
||||
import 'package:pipelines_app/features/attention/ui/notification_permission_tile.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_notifications_section.dart';
|
||||
|
||||
import 'notification_test_support.dart';
|
||||
@@ -70,13 +71,13 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SettingsNotificationsSection(controller: notify),
|
||||
),
|
||||
home: Scaffold(body: SettingsNotificationsSection(controller: notify)),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.text(notificationRationale), findsOneWidget);
|
||||
// One compact row: the short state, not the long rationale paragraph.
|
||||
expect(find.byKey(notificationStateKey), findsOneWidget);
|
||||
expect(find.text(notificationRationale), findsNothing);
|
||||
|
||||
// A denied platform answer shows its own words and no Enable action.
|
||||
final denied = NotificationController(
|
||||
@@ -86,12 +87,11 @@ void main() {
|
||||
addTearDown(denied.dispose);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SettingsNotificationsSection(controller: denied),
|
||||
),
|
||||
home: Scaffold(body: SettingsNotificationsSection(controller: denied)),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.text(notificationRationale), findsOneWidget);
|
||||
expect(find.byKey(notificationStateKey), findsOneWidget);
|
||||
expect(find.text(notificationRationale), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ void main() {
|
||||
for (final native in [false, true]) {
|
||||
final host = native ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host shows the state\'s own honest copy', (tester) async {
|
||||
testWidgets('$host shows a compact row for each state', (tester) async {
|
||||
final cases = <NotificationPermissionState, String>{
|
||||
NotificationPermissionState.unsupported: notificationUnsupportedCopy,
|
||||
NotificationPermissionState.needsSecureContext:
|
||||
@@ -46,10 +46,15 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
_page(state: entry.key, cupertino: native, onRequest: _noop),
|
||||
);
|
||||
// The Settings section owns the heading; the tile is its body.
|
||||
final view = notificationPermissionView(entry.key);
|
||||
// The Settings section owns the heading; the tile is one short row.
|
||||
expect(find.text(notificationSectionTitle), findsNothing);
|
||||
expect(find.text(notificationRationale), findsOneWidget);
|
||||
expect(find.text(entry.value), findsOneWidget, reason: '${entry.key}');
|
||||
expect(find.text(notificationRationale), findsNothing);
|
||||
expect(find.text(view.headline), findsOneWidget);
|
||||
expect(find.text(view.helper), findsOneWidget);
|
||||
// The full honest sentence is what assistive technology reads.
|
||||
expect(view.body, entry.value);
|
||||
expect(find.bySemanticsLabel(entry.value), findsOneWidget);
|
||||
expect(
|
||||
find.byKey(notificationEnableKey),
|
||||
entry.key == NotificationPermissionState.notRequested
|
||||
@@ -70,8 +75,9 @@ void main() {
|
||||
cupertino: native,
|
||||
),
|
||||
);
|
||||
expect(find.text(notificationDefaultAskedCopy), findsOneWidget);
|
||||
expect(find.text(notificationDefaultCopy), findsNothing);
|
||||
expect(find.text('Alerts are still off'), findsOneWidget);
|
||||
expect(find.bySemanticsLabel(notificationDefaultAskedCopy), findsOne);
|
||||
expect(find.bySemanticsLabel(notificationDefaultCopy), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('$host Enable runs the explicit request', (tester) async {
|
||||
@@ -115,16 +121,19 @@ void main() {
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
final rationale = tester.renderObject<RenderParagraph>(
|
||||
find.text(notificationRationale),
|
||||
final view = notificationPermissionView(
|
||||
NotificationPermissionState.notRequested,
|
||||
);
|
||||
final helper = tester.renderObject<RenderParagraph>(
|
||||
find.text(view.helper),
|
||||
);
|
||||
expect(
|
||||
rationale.size.width,
|
||||
helper.size.width,
|
||||
greaterThan(100),
|
||||
reason: 'the action must not squeeze the section copy',
|
||||
reason: 'the action must not squeeze the row copy',
|
||||
);
|
||||
final body = tester.renderObject<RenderParagraph>(
|
||||
find.text(notificationDefaultCopy),
|
||||
find.text(view.headline),
|
||||
);
|
||||
expect(body.didExceedMaxLines, isFalse);
|
||||
expect(find.byKey(notificationEnableKey), findsOneWidget);
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/decision_action.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/decision_option_row.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/decision_wording.dart';
|
||||
|
||||
typedef _Handler = Future<JsonMap> Function(String type, JsonMap fields);
|
||||
@@ -194,9 +195,33 @@ void main() {
|
||||
decisionConfirmLabel,
|
||||
);
|
||||
expect(tester.widget<CupertinoDialogAction>(confirm).onPressed, isNull);
|
||||
// Options are check-list rows, not blue link buttons: an empty circle
|
||||
// until one is picked, then a filled check on that row only.
|
||||
final skip = find.byKey(decisionOptionKey('skip'));
|
||||
expect(skip, findsOneWidget);
|
||||
expect(
|
||||
find.ancestor(
|
||||
of: find.text('skip'),
|
||||
matching: find.byType(CupertinoButton),
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.byIcon(CupertinoIcons.checkmark_circle_fill), findsNothing);
|
||||
expect(
|
||||
find.descendant(of: skip, matching: find.byIcon(CupertinoIcons.circle)),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(find.text('skip'));
|
||||
await tester.pump();
|
||||
expect(gateway.calls, isEmpty);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: skip,
|
||||
matching: find.byIcon(CupertinoIcons.checkmark_circle_fill),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byIcon(CupertinoIcons.checkmark_circle_fill), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text(decisionConfirmLabel));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -81,10 +81,13 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(
|
||||
find.text('Pipeline unavailable · 2m 5s · 3 steps'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Pipeline unavailable · 2m 5s · 3 steps'), findsOneWidget);
|
||||
});
|
||||
|
||||
test('the run action sheet is titled with the run', () {
|
||||
expect(runMoreMenuTitle(_finished), 'Ship the release notes');
|
||||
expect(runMoreMenuTitle({'id': 5, 'name': 'nightly'}), 'nightly');
|
||||
expect(runMoreMenuTitle({'id': 5}), 'Run 5');
|
||||
});
|
||||
|
||||
testWidgets('gives a list action menu a per-run key', (tester) async {
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_filter_sheet.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_filters.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_stats_page.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_sheet_header.dart';
|
||||
|
||||
class _Gateway implements ApiGateway {
|
||||
final framesController = StreamController<JsonMap>.broadcast();
|
||||
JsonMap? reply;
|
||||
|
||||
@override
|
||||
Stream<JsonMap> get frames => framesController.stream;
|
||||
|
||||
@override
|
||||
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async =>
|
||||
reply ?? {'runs': []};
|
||||
}
|
||||
|
||||
/// The Runs sheets share one header (title and Done), single-choice groups
|
||||
/// use check rows, statuses read in sentence case, and the usage page neither
|
||||
/// repeats its title nor draws a chart of zeros.
|
||||
void main() {
|
||||
late _Gateway gateway;
|
||||
late RunsController controller;
|
||||
|
||||
setUp(() {
|
||||
gateway = _Gateway();
|
||||
controller = RunsController(RunsRepository(gateway));
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
controller.dispose();
|
||||
await gateway.framesController.close();
|
||||
});
|
||||
|
||||
Future<void> mount(
|
||||
WidgetTester tester, {
|
||||
required bool cupertino,
|
||||
String? createdAt,
|
||||
}) async {
|
||||
tester.view.physicalSize = const Size(800, 1400);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final at = createdAt ?? DateTime.now().toIso8601String();
|
||||
gateway.reply = {
|
||||
'runs': [
|
||||
{
|
||||
'id': 1,
|
||||
'pipeline_id': 9,
|
||||
'name': 'Alpha',
|
||||
'status': 'running',
|
||||
'created_at': at,
|
||||
'scheduled': true,
|
||||
},
|
||||
],
|
||||
};
|
||||
await controller.load();
|
||||
final list = AnimatedBuilder(
|
||||
animation: controller,
|
||||
builder: (context, _) =>
|
||||
RunsList(controller: controller, onSelected: (_) {}),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: list))
|
||||
: MaterialApp(home: Scaffold(body: list)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host filter sheet has a header whose Done closes it', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester, cupertino: cupertino);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(AppSheetHeader), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(AppSheetHeader),
|
||||
matching: find.text(runsFilterTitle),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Queued'), findsOneWidget);
|
||||
expect(find.text('queued'), findsNothing);
|
||||
expect(find.byKey(runsFilterClearKey), findsNothing);
|
||||
|
||||
await tester.tap(find.text('Last 7 days'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.timeRange, 'last_7_days');
|
||||
// An active filter offers Clear in the header.
|
||||
expect(find.byKey(runsFilterClearKey), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(runsFilterDoneKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('runs.filter.sheet')), findsNothing);
|
||||
// The applied chip reads in sentence case too.
|
||||
expect(find.textContaining('Last 7 days'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('Material single-choice groups are check rows, not checkboxes', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester, cupertino: false);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Seven statuses may be combined: those keep their checkboxes.
|
||||
expect(find.byType(CheckboxListTile), findsNWidgets(7));
|
||||
final anyTime = find.widgetWithText(ListTile, 'Any time');
|
||||
expect(anyTime, findsOneWidget);
|
||||
expect(
|
||||
find.descendant(of: anyTime, matching: find.byIcon(Icons.check)),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(of: anyTime, matching: find.byType(Checkbox)),
|
||||
findsNothing,
|
||||
);
|
||||
final today = find.widgetWithText(ListTile, 'Today');
|
||||
expect(
|
||||
find.descendant(of: today, matching: find.byIcon(Icons.check)),
|
||||
findsNothing,
|
||||
);
|
||||
expect(tester.widget<ListTile>(anyTime).selected, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Material sort sheet has the same header', (tester) async {
|
||||
await mount(tester, cupertino: false);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.sort')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(runsSortTitle), findsOneWidget);
|
||||
await tester.tap(find.byKey(runsSortDoneKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(runsSortTitle), findsNothing);
|
||||
expect(controller.sort, 'newest_first');
|
||||
});
|
||||
|
||||
testWidgets('the usage page is honest when nothing was reported', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(
|
||||
tester,
|
||||
cupertino: false,
|
||||
createdAt: DateTime(2020, 1, 1).toIso8601String(),
|
||||
);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.stats')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// The bar says Usage; the body does not repeat it.
|
||||
expect(find.text('Usage'), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('runs.stats.usage.empty')), findsOne);
|
||||
expect(find.byKey(const ValueKey('runs.stats.days')), findsNothing);
|
||||
expect(find.byKey(const ValueKey('runs.stats.days.empty')), findsOne);
|
||||
expect(find.text('Running'), findsOneWidget);
|
||||
expect(find.text('0'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('the 7-day chart shows bars over an axis when runs started', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester, cupertino: true);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.stats')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('runs.stats.days')), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('runs.stats.days.empty')), findsNothing);
|
||||
// Only the day with a run is labelled with its count.
|
||||
final days = find.byKey(const ValueKey('runs.stats.days'));
|
||||
expect(find.descendant(of: days, matching: find.text('1')), findsOne);
|
||||
expect(find.text('0'), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
@@ -70,18 +70,22 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> reveal(WidgetTester tester, Finder target) =>
|
||||
tester.scrollUntilVisible(
|
||||
target,
|
||||
80,
|
||||
// The sheet's own list, not the search field's inner scrollable.
|
||||
scrollable: find
|
||||
.descendant(
|
||||
of: find.byKey(const ValueKey('runs.filter.sheet')),
|
||||
matching: find.byType(Scrollable),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
Future<void> reveal(WidgetTester tester, Finder target) async {
|
||||
await tester.scrollUntilVisible(
|
||||
target,
|
||||
80,
|
||||
// The sheet's own list, not the search field's inner scrollable.
|
||||
scrollable: find
|
||||
.descendant(
|
||||
of: find.byKey(const ValueKey('runs.filter.sheet')),
|
||||
matching: find.byType(Scrollable),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
// Built is not on screen: bring the row fully inside the sheet.
|
||||
await tester.ensureVisible(target);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> closeSheet(WidgetTester tester) async {
|
||||
await tester.tapAt(const Offset(4, 4));
|
||||
@@ -148,7 +152,7 @@ void main() {
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoSearchTextField), findsOneWidget);
|
||||
final failed = find.widgetWithText(CupertinoListTile, 'failed');
|
||||
final failed = find.widgetWithText(CupertinoListTile, 'Failed');
|
||||
await reveal(tester, failed);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(failed);
|
||||
@@ -156,7 +160,7 @@ void main() {
|
||||
expect(controller.statuses, {'failed'});
|
||||
await closeSheet(tester);
|
||||
|
||||
final failedChip = find.widgetWithText(CupertinoButton, 'failed');
|
||||
final failedChip = find.widgetWithText(CupertinoButton, 'Failed');
|
||||
expect(failedChip, findsOneWidget);
|
||||
expect(find.text('Alpha'), findsNothing);
|
||||
await tester.tap(failedChip);
|
||||
|
||||
@@ -154,6 +154,15 @@ void main() {
|
||||
expect(find.text('Server time 2026-10-21T12:00:00Z'), findsOneWidget);
|
||||
expect(find.byKey(SettingsKeys.disconnect), findsOneWidget);
|
||||
expect(find.byKey(SettingsKeys.connect), findsOneWidget);
|
||||
// Beside Disconnect, the second action reconnects; it never says Connect.
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(SettingsKeys.connect),
|
||||
matching: find.text('Reconnect'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Connect'), findsNothing);
|
||||
// The only other request is the ntfy settings load, queued behind ping.
|
||||
_answerNtfySettings(factory.last);
|
||||
await tester.pump();
|
||||
|
||||
Reference in New Issue
Block a user