feat(ui): improve global search with uuid and pr support (#7901)

This commit is contained in:
Alberto Rizzi
2026-02-04 19:39:57 +01:00
committed by GitHub
parent 4c3253fdf8
commit bedaed3ae6

View File

@@ -257,7 +257,7 @@ class GlobalSearch extends Component
// Get all applications // Get all applications
$applications = Application::ownedByCurrentTeam() $applications = Application::ownedByCurrentTeam()
->with(['environment.project']) ->with(['environment.project', 'previews:id,application_id,pull_request_id'])
->get() ->get()
->map(function ($app) { ->map(function ($app) {
// Collect all FQDNs from the application // Collect all FQDNs from the application
@@ -286,6 +286,16 @@ class GlobalSearch extends Component
$fqdnsString = $fqdns->implode(' '); $fqdnsString = $fqdns->implode(' ');
// Add PR search terms if preview is enabled
$prSearchTerms = '';
if ($app->preview_enabled ?? false) {
$prIds = collect($app->previews ?? [])
->pluck('pull_request_id')
->map(fn ($id) => "pr-{$id} pr{$id} {$id}")
->implode(' ');
$prSearchTerms = $prIds;
}
return [ return [
'id' => $app->id, 'id' => $app->id,
'name' => $app->name, 'name' => $app->name,
@@ -296,13 +306,13 @@ class GlobalSearch extends Component
'project' => $app->environment->project->name ?? null, 'project' => $app->environment->project->name ?? null,
'environment' => $app->environment->name ?? null, 'environment' => $app->environment->name ?? null,
'fqdns' => $fqdns->take(2)->implode(', '), // Show first 2 FQDNs in UI 'fqdns' => $fqdns->take(2)->implode(', '), // Show first 2 FQDNs in UI
'search_text' => strtolower($app->name.' '.$app->description.' '.$fqdnsString.' application applications app apps'), 'search_text' => strtolower($app->name.' '.$app->description.' '.$fqdnsString.' '.$app->uuid.' '.$prSearchTerms.' application applications app apps'),
]; ];
}); });
// Get all services // Get all services
$services = Service::ownedByCurrentTeam() $services = Service::ownedByCurrentTeam()
->with(['environment.project', 'applications']) ->with(['environment.project', 'applications', 'databases'])
->get() ->get()
->map(function ($service) { ->map(function ($service) {
// Collect all FQDNs from service applications // Collect all FQDNs from service applications
@@ -315,6 +325,10 @@ class GlobalSearch extends Component
} }
$fqdnsString = $fqdns->implode(' '); $fqdnsString = $fqdns->implode(' ');
// Collect service component names for container search
$serviceAppNames = collect($service->applications ?? [])->pluck('name')->implode(' ');
$serviceDbNames = collect($service->databases ?? [])->pluck('name')->implode(' ');
return [ return [
'id' => $service->id, 'id' => $service->id,
'name' => $service->name, 'name' => $service->name,
@@ -325,7 +339,7 @@ class GlobalSearch extends Component
'project' => $service->environment->project->name ?? null, 'project' => $service->environment->project->name ?? null,
'environment' => $service->environment->name ?? null, 'environment' => $service->environment->name ?? null,
'fqdns' => $fqdns->take(2)->implode(', '), // Show first 2 FQDNs in UI 'fqdns' => $fqdns->take(2)->implode(', '), // Show first 2 FQDNs in UI
'search_text' => strtolower($service->name.' '.$service->description.' '.$fqdnsString.' service services'), 'search_text' => strtolower($service->name.' '.$service->description.' '.$fqdnsString.' '.$service->uuid.' '.$serviceAppNames.' '.$serviceDbNames.' service services'),
]; ];
}); });
@@ -348,7 +362,7 @@ class GlobalSearch extends Component
'link' => $db->link(), 'link' => $db->link(),
'project' => $db->environment->project->name ?? null, 'project' => $db->environment->project->name ?? null,
'environment' => $db->environment->name ?? null, 'environment' => $db->environment->name ?? null,
'search_text' => strtolower($db->name.' postgresql '.$db->description.' database databases db'), 'search_text' => strtolower($db->name.' '.$db->uuid.' postgresql '.$db->description.' database databases db'),
]; ];
}) })
); );
@@ -369,7 +383,7 @@ class GlobalSearch extends Component
'link' => $db->link(), 'link' => $db->link(),
'project' => $db->environment->project->name ?? null, 'project' => $db->environment->project->name ?? null,
'environment' => $db->environment->name ?? null, 'environment' => $db->environment->name ?? null,
'search_text' => strtolower($db->name.' mysql '.$db->description.' database databases db'), 'search_text' => strtolower($db->name.' '.$db->uuid.' mysql '.$db->description.' database databases db'),
]; ];
}) })
); );
@@ -390,7 +404,7 @@ class GlobalSearch extends Component
'link' => $db->link(), 'link' => $db->link(),
'project' => $db->environment->project->name ?? null, 'project' => $db->environment->project->name ?? null,
'environment' => $db->environment->name ?? null, 'environment' => $db->environment->name ?? null,
'search_text' => strtolower($db->name.' mariadb '.$db->description.' database databases db'), 'search_text' => strtolower($db->name.' '.$db->uuid.' mariadb '.$db->description.' database databases db'),
]; ];
}) })
); );
@@ -411,7 +425,7 @@ class GlobalSearch extends Component
'link' => $db->link(), 'link' => $db->link(),
'project' => $db->environment->project->name ?? null, 'project' => $db->environment->project->name ?? null,
'environment' => $db->environment->name ?? null, 'environment' => $db->environment->name ?? null,
'search_text' => strtolower($db->name.' mongodb '.$db->description.' database databases db'), 'search_text' => strtolower($db->name.' '.$db->uuid.' mongodb '.$db->description.' database databases db'),
]; ];
}) })
); );
@@ -432,7 +446,7 @@ class GlobalSearch extends Component
'link' => $db->link(), 'link' => $db->link(),
'project' => $db->environment->project->name ?? null, 'project' => $db->environment->project->name ?? null,
'environment' => $db->environment->name ?? null, 'environment' => $db->environment->name ?? null,
'search_text' => strtolower($db->name.' redis '.$db->description.' database databases db'), 'search_text' => strtolower($db->name.' '.$db->uuid.' redis '.$db->description.' database databases db'),
]; ];
}) })
); );
@@ -453,7 +467,7 @@ class GlobalSearch extends Component
'link' => $db->link(), 'link' => $db->link(),
'project' => $db->environment->project->name ?? null, 'project' => $db->environment->project->name ?? null,
'environment' => $db->environment->name ?? null, 'environment' => $db->environment->name ?? null,
'search_text' => strtolower($db->name.' keydb '.$db->description.' database databases db'), 'search_text' => strtolower($db->name.' '.$db->uuid.' keydb '.$db->description.' database databases db'),
]; ];
}) })
); );
@@ -474,7 +488,7 @@ class GlobalSearch extends Component
'link' => $db->link(), 'link' => $db->link(),
'project' => $db->environment->project->name ?? null, 'project' => $db->environment->project->name ?? null,
'environment' => $db->environment->name ?? null, 'environment' => $db->environment->name ?? null,
'search_text' => strtolower($db->name.' dragonfly '.$db->description.' database databases db'), 'search_text' => strtolower($db->name.' '.$db->uuid.' dragonfly '.$db->description.' database databases db'),
]; ];
}) })
); );
@@ -495,7 +509,7 @@ class GlobalSearch extends Component
'link' => $db->link(), 'link' => $db->link(),
'project' => $db->environment->project->name ?? null, 'project' => $db->environment->project->name ?? null,
'environment' => $db->environment->name ?? null, 'environment' => $db->environment->name ?? null,
'search_text' => strtolower($db->name.' clickhouse '.$db->description.' database databases db'), 'search_text' => strtolower($db->name.' '.$db->uuid.' clickhouse '.$db->description.' database databases db'),
]; ];
}) })
); );