feat(app): an open run takes over the app bar (Back, run, more menu); Search is the fifth tab; tabs keep their last screen
This commit is contained in:
@@ -56,8 +56,9 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
_searchReturn = initial.kind == AppRouteKind.search
|
||||
? AppRoute.pipelines
|
||||
: initial,
|
||||
_templatesReturn = initial.kind == AppRouteKind.templates
|
||||
|| initial.kind == AppRouteKind.schedules
|
||||
_templatesReturn =
|
||||
initial.kind == AppRouteKind.templates ||
|
||||
initial.kind == AppRouteKind.schedules
|
||||
? AppRoute.settings
|
||||
: initial;
|
||||
|
||||
@@ -111,7 +112,7 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
/// The route the shell renders underneath the transient Search, Templates
|
||||
/// and Schedules pages. Those pages keep the shell mounted, so the route the
|
||||
/// operator last opened there is still the shell's own destination.
|
||||
AppRoute get shellRoute => searchOpen
|
||||
AppRoute get shellRoute => searchOpen && searchBuilder != null
|
||||
? _searchReturn
|
||||
: templatesOpen || schedulesOpen
|
||||
? _templatesReturn
|
||||
@@ -256,7 +257,8 @@ RouteInformation initialRouteInformation() {
|
||||
if (!kIsWeb) {
|
||||
// A cold start from a deep link carries the full link as the platform's
|
||||
// initial route; an ordinary launch opens the Pipelines list.
|
||||
final launched = WidgetsBinding.instance.platformDispatcher.defaultRouteName;
|
||||
final launched =
|
||||
WidgetsBinding.instance.platformDispatcher.defaultRouteName;
|
||||
return RouteInformation(
|
||||
uri: launched.isEmpty || launched == '/'
|
||||
? Uri(path: '/pipelines')
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../core/api_gateway.dart';
|
||||
@@ -149,12 +148,13 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
cupertino: _cupertino,
|
||||
onPopToRuns: () => _delegate.goTo(AppRoute.runs),
|
||||
onPopToChat: () => _delegate.goTo(AppRoute.chat),
|
||||
searchBuilder: _buildSearch,
|
||||
templatesBuilder: _buildTemplates,
|
||||
schedulesBuilder: _buildSchedules,
|
||||
builder: _buildShell,
|
||||
);
|
||||
_delegate.addListener(_routeChanged);
|
||||
_tabRoutes[_destinationOf(_delegate.shellRoute.kind)] =
|
||||
_delegate.shellRoute;
|
||||
_chatQuestionNotices = ChatQuestionNotices(
|
||||
gateway: _session.gateway,
|
||||
canNotify: () => _notifications.canNotify,
|
||||
@@ -264,19 +264,6 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
Widget build(BuildContext context) =>
|
||||
MyApp.router(cupertino: _cupertino, routerConfig: _config);
|
||||
|
||||
/// The transient Search page. Escape matches the browser's panel shortcut;
|
||||
/// the native Back button and browser Back come from the router and page.
|
||||
Widget _buildSearch(BuildContext context) => CallbackShortcuts(
|
||||
bindings: {
|
||||
const SingleActivator(LogicalKeyboardKey.escape): _delegate.closeSearch,
|
||||
},
|
||||
child: SearchDestination(
|
||||
session: _session,
|
||||
server: widget.server,
|
||||
onOpen: _openSearchResult,
|
||||
),
|
||||
);
|
||||
|
||||
/// Open a result through the exact identity the hit records. An unresolvable
|
||||
/// hit navigates nowhere: the screen already presents it read-only rather than
|
||||
/// guessing a destination.
|
||||
@@ -336,7 +323,21 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
/// a failed detail, would otherwise keep the request for the next unrelated
|
||||
/// visit to the same run. Search/Templates/Schedules pages above the run keep
|
||||
/// it, because the shell route underneath them still names that run.
|
||||
/// The last route each tab showed, so switching tabs returns to where the
|
||||
/// operator left it; tapping the open tab again goes to its root.
|
||||
final Map<AppDestination, AppRoute> _tabRoutes = {};
|
||||
|
||||
void _selectDestination(AppDestination destination) {
|
||||
final current = _destinationOf(_delegate.shellRoute.kind);
|
||||
final last = _tabRoutes[destination];
|
||||
_delegate.goTo(
|
||||
destination == current || last == null ? _routeOf(destination) : last,
|
||||
);
|
||||
}
|
||||
|
||||
void _routeChanged() {
|
||||
final shown = _delegate.shellRoute;
|
||||
_tabRoutes[_destinationOf(shown.kind)] = shown;
|
||||
final pending = _pendingRunSearch;
|
||||
if (!mounted || pending == null) return;
|
||||
final route = _delegate.shellRoute;
|
||||
@@ -397,76 +398,91 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
builder: (context, count, _) => _shellFor(route, count),
|
||||
);
|
||||
|
||||
Widget _shellFor(AppRoute route, int attentionCount) => AdaptiveShell(
|
||||
attentionCount: attentionCount,
|
||||
cupertino: _cupertino,
|
||||
destination: _destinationOf(route.kind),
|
||||
onDestinationSelected: (destination) =>
|
||||
_delegate.goTo(_routeOf(destination)),
|
||||
onSearch: _delegate.openSearch,
|
||||
destinationBodies: {
|
||||
AppDestination.pipelines: (_) => PipelinesDestination(
|
||||
session: _session,
|
||||
server: widget.server,
|
||||
refreshToken: _pipelinesRefresh,
|
||||
onRunStarted: _runStarted,
|
||||
onViewPipelineRuns: (id) =>
|
||||
_delegate.goTo(AppRoute.runsForPipeline(id)),
|
||||
initialPipelineId: route.pipelineId,
|
||||
initialVersion: route.version,
|
||||
initialStageKey: route.stageKey,
|
||||
),
|
||||
// The one place a field or artifact hit's selection can be resolved: the
|
||||
// run detail owns the recorded visit and Summary section.
|
||||
AppDestination.runs: (_) => RunSearchSelectionScope(
|
||||
selection: _pendingRunSearch,
|
||||
onConsumed: _runSearchConsumed,
|
||||
child: RunsDestination(
|
||||
Widget _shellFor(AppRoute route, int attentionCount) {
|
||||
// Each tab is built from the route it last showed, so switching tabs keeps
|
||||
// an open run, pipeline or chat instead of resetting it.
|
||||
AppRoute tab(AppDestination destination) =>
|
||||
_destinationOf(route.kind) == destination
|
||||
? route
|
||||
: _tabRoutes[destination] ?? _routeOf(destination);
|
||||
final pipelinesRoute = tab(AppDestination.pipelines);
|
||||
final runsRoute = tab(AppDestination.runs);
|
||||
final chatRoute = tab(AppDestination.chat);
|
||||
return AdaptiveShell(
|
||||
attentionCount: attentionCount,
|
||||
cupertino: _cupertino,
|
||||
destination: _destinationOf(route.kind),
|
||||
onDestinationSelected: _selectDestination,
|
||||
destinationBodies: {
|
||||
AppDestination.pipelines: (_) => PipelinesDestination(
|
||||
session: _session,
|
||||
server: widget.server,
|
||||
initialRunId: route.runId,
|
||||
initialPipelineId: route.pipelineId,
|
||||
initialStageKey: route.stageKey,
|
||||
initialVisit: route.visit,
|
||||
initialDecide: route.decide,
|
||||
listRefreshToken: _runsRefresh,
|
||||
notifications: _notifications,
|
||||
attention: _attention,
|
||||
onRunSelected: (id) => _delegate.goTo(AppRoute.run(id)),
|
||||
onBack: (id) => _delegate.goTo(
|
||||
id == null ? AppRoute.runs : AppRoute.runsForPipeline(id),
|
||||
),
|
||||
onPipelineFilterChanged: (id) => _delegate.goTo(
|
||||
id == null ? AppRoute.runs : AppRoute.runsForPipeline(id),
|
||||
),
|
||||
onOpenPipeline: (id, version) =>
|
||||
_delegate.goTo(AppRoute.pipeline(id, version: version)),
|
||||
refreshToken: _pipelinesRefresh,
|
||||
onRunStarted: _runStarted,
|
||||
onViewPipelineRuns: (id) =>
|
||||
_delegate.goTo(AppRoute.runsForPipeline(id)),
|
||||
initialPipelineId: pipelinesRoute.pipelineId,
|
||||
initialVersion: pipelinesRoute.version,
|
||||
initialStageKey: pipelinesRoute.stageKey,
|
||||
),
|
||||
),
|
||||
AppDestination.chat: (_) => ChatDestination(
|
||||
session: _session,
|
||||
server: widget.server,
|
||||
initialSessionId: route.chatSessionId,
|
||||
onSessionSelected: (id) => _delegate.goTo(AppRoute.chatSession(id)),
|
||||
onBack: () => _delegate.goTo(AppRoute.chat),
|
||||
),
|
||||
AppDestination.settings: (_) => SettingsScreen(
|
||||
client: _session.client,
|
||||
initialEndpoint: _session.endpoint,
|
||||
embedded: true,
|
||||
onOpenTemplates: _delegate.openTemplates,
|
||||
onOpenSchedules: _delegate.openSchedules,
|
||||
notifications: _notifications,
|
||||
),
|
||||
},
|
||||
);
|
||||
// The one place a field or artifact hit's selection can be resolved: the
|
||||
// run detail owns the recorded visit and Summary section.
|
||||
AppDestination.runs: (_) => RunSearchSelectionScope(
|
||||
selection: _pendingRunSearch,
|
||||
onConsumed: _runSearchConsumed,
|
||||
child: RunsDestination(
|
||||
session: _session,
|
||||
server: widget.server,
|
||||
initialRunId: runsRoute.runId,
|
||||
initialPipelineId: runsRoute.pipelineId,
|
||||
initialStageKey: runsRoute.stageKey,
|
||||
initialVisit: runsRoute.visit,
|
||||
initialDecide: runsRoute.decide,
|
||||
listRefreshToken: _runsRefresh,
|
||||
notifications: _notifications,
|
||||
attention: _attention,
|
||||
onRunSelected: (id) => _delegate.goTo(AppRoute.run(id)),
|
||||
onBack: (id) => _delegate.goTo(
|
||||
id == null ? AppRoute.runs : AppRoute.runsForPipeline(id),
|
||||
),
|
||||
onPipelineFilterChanged: (id) => _delegate.goTo(
|
||||
id == null ? AppRoute.runs : AppRoute.runsForPipeline(id),
|
||||
),
|
||||
onOpenPipeline: (id, version) =>
|
||||
_delegate.goTo(AppRoute.pipeline(id, version: version)),
|
||||
),
|
||||
),
|
||||
AppDestination.chat: (_) => ChatDestination(
|
||||
session: _session,
|
||||
server: widget.server,
|
||||
initialSessionId: chatRoute.chatSessionId,
|
||||
onSessionSelected: (id) => _delegate.goTo(AppRoute.chatSession(id)),
|
||||
onBack: () => _delegate.goTo(AppRoute.chat),
|
||||
),
|
||||
// Search is the fifth tab; a result opens its destination.
|
||||
AppDestination.search: (_) => SearchDestination(
|
||||
session: _session,
|
||||
server: widget.server,
|
||||
onOpen: _openSearchResult,
|
||||
embedded: true,
|
||||
),
|
||||
AppDestination.settings: (_) => SettingsScreen(
|
||||
client: _session.client,
|
||||
initialEndpoint: _session.endpoint,
|
||||
embedded: true,
|
||||
onOpenTemplates: _delegate.openTemplates,
|
||||
onOpenSchedules: _delegate.openSchedules,
|
||||
notifications: _notifications,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
AppDestination _destinationOf(AppRouteKind kind) => switch (kind) {
|
||||
AppRouteKind.pipelines => AppDestination.pipelines,
|
||||
AppRouteKind.runs => AppDestination.runs,
|
||||
AppRouteKind.chat => AppDestination.chat,
|
||||
// Search is a transient page above the shell; it never becomes a tab.
|
||||
AppRouteKind.search => AppDestination.pipelines,
|
||||
AppRouteKind.search => AppDestination.search,
|
||||
AppRouteKind.settings => AppDestination.settings,
|
||||
// Templates and Schedules are Settings sub-pages, not a fifth tab.
|
||||
AppRouteKind.templates => AppDestination.settings,
|
||||
@@ -477,6 +493,7 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
AppDestination.pipelines => AppRoute.pipelines,
|
||||
AppDestination.runs => AppRoute.runs,
|
||||
AppDestination.chat => AppRoute.chat,
|
||||
AppDestination.search => AppRoute.search,
|
||||
AppDestination.settings => AppRoute.settings,
|
||||
};
|
||||
|
||||
|
||||
@@ -22,12 +22,16 @@ class SearchDestination extends StatefulWidget {
|
||||
required this.session,
|
||||
required this.server,
|
||||
required this.onOpen,
|
||||
this.embedded = false,
|
||||
});
|
||||
|
||||
final AppSession session;
|
||||
final ServerEndpoint server;
|
||||
final ValueChanged<JsonMap> onOpen;
|
||||
|
||||
/// True as the shell's Search tab: no page chrome of its own.
|
||||
final bool embedded;
|
||||
|
||||
@override
|
||||
State<SearchDestination> createState() => _SearchDestinationState();
|
||||
}
|
||||
@@ -75,6 +79,15 @@ class _SearchDestinationState extends State<SearchDestination> {
|
||||
builder: (context, _) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
if (!widget.session.everConnected || !_entered) {
|
||||
if (widget.embedded) {
|
||||
return _entered
|
||||
? ConnectionGate(
|
||||
session: widget.session,
|
||||
server: widget.server,
|
||||
cupertino: cupertino,
|
||||
)
|
||||
: const SizedBox.shrink();
|
||||
}
|
||||
return _SearchPage(
|
||||
cupertino: cupertino,
|
||||
child: _entered
|
||||
@@ -90,6 +103,7 @@ class _SearchDestinationState extends State<SearchDestination> {
|
||||
gateway: widget.session.gateway,
|
||||
onOpen: widget.onOpen,
|
||||
cupertino: cupertino,
|
||||
embedded: widget.embedded,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user