diff --git a/app/lib/application/pipelines_app.dart b/app/lib/application/pipelines_app.dart index bfba4037..599ed150 100644 --- a/app/lib/application/pipelines_app.dart +++ b/app/lib/application/pipelines_app.dart @@ -421,6 +421,7 @@ class _PipelinesAppState extends State onRunStarted: _runStarted, onViewPipelineRuns: (id) => _delegate.goTo(AppRoute.runsForPipeline(id)), + onOpenSchedules: _delegate.openSchedules, initialPipelineId: pipelinesRoute.pipelineId, initialVersion: pipelinesRoute.version, initialStageKey: pipelinesRoute.stageKey, @@ -473,7 +474,6 @@ class _PipelinesAppState extends State initialEndpoint: _session.endpoint, embedded: true, onOpenTemplates: _delegate.openTemplates, - onOpenSchedules: _delegate.openSchedules, notifications: _notifications, ), }, diff --git a/app/lib/application/pipelines_destination.dart b/app/lib/application/pipelines_destination.dart index bf11fa06..9cc0974c 100644 --- a/app/lib/application/pipelines_destination.dart +++ b/app/lib/application/pipelines_destination.dart @@ -20,6 +20,7 @@ class PipelinesDestination extends StatelessWidget { this.refreshToken = 0, this.onRunStarted, this.onViewPipelineRuns, + this.onOpenSchedules, this.initialPipelineId, this.initialVersion = 0, this.initialStageKey, @@ -36,6 +37,7 @@ class PipelinesDestination extends StatelessWidget { /// Receives the run id an accepted launch named; the shell opens that route. final ValueChanged? onRunStarted; final ValueChanged? onViewPipelineRuns; + final VoidCallback? onOpenSchedules; /// The pipeline and pinned version a deep link names. final int? initialPipelineId; @@ -81,6 +83,7 @@ class PipelinesDestination extends StatelessWidget { embedded: true, onRunStarted: onRunStarted, onViewPipelineRuns: onViewPipelineRuns, + onOpenSchedules: onOpenSchedules, initialPipelineId: initialPipelineId, initialVersion: initialVersion, initialStageKey: initialStageKey, diff --git a/app/lib/features/pipelines/screen.dart b/app/lib/features/pipelines/screen.dart index 54c8f80b..7d75eb7f 100644 --- a/app/lib/features/pipelines/screen.dart +++ b/app/lib/features/pipelines/screen.dart @@ -32,6 +32,7 @@ class PipelinesScreen extends StatefulWidget { this.syncToken = 0, this.onRunStarted, this.onViewPipelineRuns, + this.onOpenSchedules, this.initialPipelineId, this.initialVersion = 0, this.initialStageKey, @@ -54,6 +55,9 @@ class PipelinesScreen extends StatefulWidget { final ValueChanged? onRunStarted; final ValueChanged? onViewPipelineRuns; + /// Opens every schedule; shown in the bar while the list is visible. + final VoidCallback? onOpenSchedules; + /// The pipeline a deep link names, opened after the list read starts. final int? initialPipelineId; @@ -234,6 +238,8 @@ class _PipelinesScreenState extends State { return ShellBar( actions: [ if (listShown) ...pipelineListActions(context, _controller), + if (listShown && widget.onOpenSchedules != null) + _schedulesButton(context), _refreshButton(context), ], child: body, @@ -250,6 +256,7 @@ class _PipelinesScreenState extends State { mainAxisSize: MainAxisSize.min, children: [ ...pipelineListActions(context, _controller), + if (widget.onOpenSchedules != null) _schedulesButton(context), _refreshButton(context), ], ), @@ -260,6 +267,27 @@ class _PipelinesScreenState extends State { ); } + Widget _schedulesButton(BuildContext context) { + if (useCupertinoControls(context)) { + return Semantics( + button: true, + label: 'Schedules', + child: CupertinoButton( + key: const Key('pipelines-open-schedules'), + padding: EdgeInsets.zero, + onPressed: widget.onOpenSchedules, + child: const Icon(CupertinoIcons.calendar), + ), + ); + } + return IconButton( + key: const Key('pipelines-open-schedules'), + tooltip: 'Schedules', + onPressed: widget.onOpenSchedules, + icon: const Icon(Icons.schedule), + ); + } + Widget _refreshButton(BuildContext context) { if (useCupertinoControls(context)) { return Semantics( @@ -295,6 +323,7 @@ class _PipelinesScreenState extends State { title: const Text('Pipelines'), actions: [ ...pipelineListActions(context, _controller), + if (widget.onOpenSchedules != null) _schedulesButton(context), _refreshButton(context), ], ), @@ -310,6 +339,7 @@ class _PipelinesScreenState extends State { mainAxisSize: MainAxisSize.min, children: [ ...pipelineListActions(context, _controller), + if (widget.onOpenSchedules != null) _schedulesButton(context), _refreshButton(context), ], ), diff --git a/app/test/features/pipelines/pipelines_screen_filter_test.dart b/app/test/features/pipelines/pipelines_screen_filter_test.dart index ced73e54..e9dccc19 100644 --- a/app/test/features/pipelines/pipelines_screen_filter_test.dart +++ b/app/test/features/pipelines/pipelines_screen_filter_test.dart @@ -1,3 +1,4 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/features/pipelines/screen.dart'; @@ -146,4 +147,22 @@ void main() { await tester.pumpAndSettle(); expect(find.text('Beta deploy'), findsOneWidget); }); + + for (final cupertino in [false, true]) { + testWidgets('Schedules opens from the bar (cupertino: $cupertino)', ( + tester, + ) async { + var opened = 0; + final screen = PipelinesScreen( + gateway: gatewayFor(PipelineFixture()), + onOpenSchedules: () => opened++, + ); + await tester.pumpWidget( + cupertino ? CupertinoApp(home: screen) : MaterialApp(home: screen), + ); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('pipelines-open-schedules'))); + expect(opened, 1); + }); + } }