feat(app): open pipeline and template deep links and route search results
This commit is contained in:
@@ -10,6 +10,7 @@ import '../shell/adaptive_shell.dart';
|
||||
import '../shell/destination.dart';
|
||||
import '../features/attention/notify/notification_controller.dart';
|
||||
import '../features/attention/notify/notification_store.dart';
|
||||
import '../features/search/domain/search_target.dart';
|
||||
import '../features/settings/settings_screen.dart';
|
||||
import 'app.dart';
|
||||
import 'app_route.dart';
|
||||
@@ -136,12 +137,28 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
||||
),
|
||||
);
|
||||
|
||||
/// Open a result through an existing app route only. A run target uses the
|
||||
/// route the Runs destination already owns; the hit map itself is unchanged,
|
||||
/// and pipeline/version hits have no route yet, so they are not guessed.
|
||||
/// 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.
|
||||
void _openSearchResult(JsonMap hit) {
|
||||
final runId = searchHitRunId(hit);
|
||||
if (runId != null) _delegate.goTo(AppRoute.run(runId));
|
||||
final resolved = searchTargetFor(hit);
|
||||
if (resolved is! ResolvedSearchTarget) return;
|
||||
final route = switch (resolved.target) {
|
||||
SearchPipelineTarget(:final pipelineId) => AppRoute.pipeline(pipelineId),
|
||||
SearchVersionTarget(:final pipelineId, :final version) =>
|
||||
AppRoute.pipeline(pipelineId, version: version),
|
||||
SearchRunTarget(:final runId) => AppRoute.run(runId),
|
||||
SearchStepTarget(:final runId, :final stage, :final visit) =>
|
||||
stage == null
|
||||
? AppRoute.run(runId)
|
||||
: AppRoute.run.stage(runId, stage, visit: visit),
|
||||
// A field or artifact names a visit inside the run; the run detail owns
|
||||
// that pane, so open the run rather than inventing a stage route.
|
||||
SearchFieldTarget(:final runId) => AppRoute.run(runId),
|
||||
SearchArtifactTarget(:final runId) =>
|
||||
runId == null ? null : AppRoute.run(runId),
|
||||
};
|
||||
if (route != null) _delegate.goTo(route);
|
||||
}
|
||||
|
||||
/// The Templates page above Settings. Closing it restores the same Settings
|
||||
@@ -151,6 +168,7 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
||||
server: widget.server,
|
||||
onBack: _delegate.closeTemplates,
|
||||
onCreated: _templateCreated,
|
||||
initialKey: _delegate.route.templateKey,
|
||||
);
|
||||
|
||||
/// An accepted create only invalidates Pipelines; the list is re-read and the
|
||||
@@ -183,6 +201,8 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
||||
server: widget.server,
|
||||
refreshToken: _pipelinesRefresh,
|
||||
onRunStarted: _runStarted,
|
||||
initialPipelineId: route.pipelineId,
|
||||
initialVersion: route.version,
|
||||
),
|
||||
AppDestination.runs: (_) => RunsDestination(
|
||||
session: _session,
|
||||
|
||||
@@ -19,6 +19,8 @@ class PipelinesDestination extends StatelessWidget {
|
||||
required this.server,
|
||||
this.refreshToken = 0,
|
||||
this.onRunStarted,
|
||||
this.initialPipelineId,
|
||||
this.initialVersion = 0,
|
||||
});
|
||||
|
||||
final AppSession session;
|
||||
@@ -32,6 +34,10 @@ class PipelinesDestination extends StatelessWidget {
|
||||
/// Receives the run id an accepted launch named; the shell opens that route.
|
||||
final ValueChanged<int>? onRunStarted;
|
||||
|
||||
/// The pipeline and pinned version a deep link names.
|
||||
final int? initialPipelineId;
|
||||
final int initialVersion;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => AnimatedBuilder(
|
||||
animation: session,
|
||||
@@ -67,6 +73,8 @@ class PipelinesDestination extends StatelessWidget {
|
||||
gateway: session.gateway,
|
||||
embedded: true,
|
||||
onRunStarted: onRunStarted,
|
||||
initialPipelineId: initialPipelineId,
|
||||
initialVersion: initialVersion,
|
||||
// A reconnect or an accepted template create both advance this counter;
|
||||
// either change re-reads through the mounted controller.
|
||||
syncToken: session.connectionEpoch + refreshToken,
|
||||
|
||||
@@ -28,6 +28,7 @@ class TemplatesDestination extends StatelessWidget {
|
||||
required this.server,
|
||||
required this.onBack,
|
||||
this.onCreated,
|
||||
this.initialKey,
|
||||
});
|
||||
|
||||
final AppSession session;
|
||||
@@ -37,6 +38,9 @@ class TemplatesDestination extends StatelessWidget {
|
||||
final VoidCallback onBack;
|
||||
final ValueChanged<JsonMap>? onCreated;
|
||||
|
||||
/// The template detail the route names, or null for the gallery.
|
||||
final String? initialKey;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
@@ -67,6 +71,7 @@ class TemplatesDestination extends StatelessWidget {
|
||||
gateway: session.gateway,
|
||||
embedded: true,
|
||||
onCreated: onCreated,
|
||||
initialKey: initialKey,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user