merge(app): land pipelines scope switch
This commit is contained in:
@@ -37,6 +37,7 @@ class PipelineListPanel extends StatelessWidget {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_scope(context, filters),
|
||||
_toolbar(context, filters, hasUnclassified),
|
||||
if (controller.listError != null)
|
||||
PipelineErrorBanner(
|
||||
@@ -62,6 +63,42 @@ class PipelineListPanel extends StatelessWidget {
|
||||
|
||||
/// The web's compact toolbar: filter (whose page carries the name search),
|
||||
/// sort and clear, on the list's 12px inset with a separator underneath.
|
||||
/// All pipelines, or only those with a schedule.
|
||||
Widget _scope(BuildContext context, PipelineFilters filters) {
|
||||
final scheduled = filters.schedule == ScheduleFilter.scheduled;
|
||||
void pick(bool value) => controller.setFilters(
|
||||
filters.copyWith(
|
||||
schedule: value ? ScheduleFilter.scheduled : ScheduleFilter.any,
|
||||
),
|
||||
);
|
||||
final control = useCupertinoControls(context)
|
||||
? CupertinoSlidingSegmentedControl<bool>(
|
||||
key: const Key('pipeline-scope'),
|
||||
groupValue: scheduled,
|
||||
onValueChanged: (value) => pick(value ?? false),
|
||||
children: const {false: Text('All'), true: Text('Scheduled')},
|
||||
)
|
||||
: SegmentedButton<bool>(
|
||||
key: const Key('pipeline-scope'),
|
||||
showSelectedIcon: false,
|
||||
segments: const [
|
||||
ButtonSegment(value: false, label: Text('All')),
|
||||
ButtonSegment(value: true, label: Text('Scheduled')),
|
||||
],
|
||||
selected: {scheduled},
|
||||
onSelectionChanged: (value) => pick(value.single),
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
kPipelineListInset,
|
||||
6,
|
||||
kPipelineListInset,
|
||||
4,
|
||||
),
|
||||
child: SizedBox(width: double.infinity, child: control),
|
||||
);
|
||||
}
|
||||
|
||||
/// Filter and sort are in the app bar; only an active filter keeps a
|
||||
/// one-tap way back here.
|
||||
Widget _toolbar(
|
||||
|
||||
@@ -117,4 +117,33 @@ void main() {
|
||||
expect(find.text('Retry'), findsOneWidget);
|
||||
expect(find.text('Select a pipeline.'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('the list switches between all and scheduled pipelines', (
|
||||
tester,
|
||||
) async {
|
||||
final fixture = PipelineFixture();
|
||||
await pumpWide(tester, gatewayFor(fixture));
|
||||
expect(find.text('Alpha review'), findsOneWidget);
|
||||
expect(find.text('Gamma legacy'), findsOneWidget);
|
||||
|
||||
await tester.tap(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('pipeline-scope')),
|
||||
matching: find.text('Scheduled'),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
// Beta has no schedule in the fixture; Alpha has one.
|
||||
expect(find.text('Alpha review'), findsOneWidget);
|
||||
expect(find.text('Beta deploy'), findsNothing);
|
||||
|
||||
await tester.tap(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('pipeline-scope')),
|
||||
matching: find.text('All'),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Beta deploy'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user