diff --git a/app/Livewire/GlobalSearch.php b/app/Livewire/GlobalSearch.php index 680ac7701..e1dd678ff 100644 --- a/app/Livewire/GlobalSearch.php +++ b/app/Livewire/GlobalSearch.php @@ -1147,6 +1147,9 @@ private function navigateToResourceCreation($type) $this->selectedResourceType = $type; $this->isSelectingResource = true; + // Clear search query to show selection UI instead of creatable items + $this->searchQuery = ''; + // Reset selections $this->selectedServerId = null; $this->selectedDestinationUuid = null; @@ -1316,10 +1319,10 @@ private function completeResourceCreation() $queryParams['database_image'] = 'postgres:16-alpine'; } - return redirect()->route('project.resource.create', [ + $this->redirect(route('project.resource.create', [ 'project_uuid' => $this->selectedProjectUuid, 'environment_uuid' => $this->selectedEnvironmentUuid, - ] + $queryParams); + ] + $queryParams)); } } diff --git a/resources/views/livewire/global-search.blade.php b/resources/views/livewire/global-search.blade.php index 06da31354..f8fa8ec7d 100644 --- a/resources/views/livewire/global-search.blade.php +++ b/resources/views/livewire/global-search.blade.php @@ -136,13 +136,17 @@ 'new postgresql', 'new postgres', 'new mysql', 'new mariadb', 'new redis', 'new keydb', 'new dragonfly', 'new mongodb', 'new mongo', 'new clickhouse' ]; - if (exactMatchCommands.includes(trimmed)) { const matchingItem = this.creatableItems.find(item => { const itemSearchText = `new ${item.name}`.toLowerCase(); const itemType = `new ${item.type}`.toLowerCase(); - return itemSearchText === trimmed || itemType === trimmed || - (item.type && trimmed.includes(item.type.replace(/-/g, ' '))); + const itemTypeWithSpaces = item.type ? `new ${item.type.replace(/-/g, ' ')}` : ''; + + // Check if trimmed matches exactly or if the item's quickcommand includes this command + return itemSearchText === trimmed || + itemType === trimmed || + itemTypeWithSpaces === trimmed || + (item.quickcommand && item.quickcommand.toLowerCase().includes(trimmed)); }); if (matchingItem) { @@ -250,8 +254,7 @@ class="fixed top-0 left-0 z-99 flex items-start justify-center w-screen h-screen pt-[10vh]">
-
- + @@ -307,8 +311,8 @@ class="mt-2 bg-white dark:bg-coolgray-100 rounded-lg shadow-xl ring-1 ring-neutr class="text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white"> - +
@@ -323,11 +327,13 @@ class="text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:
@if ($loadingServers) -
- - +
+ + @@ -337,7 +343,8 @@ class="text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:
@elseif (count($availableServers) > 0) @foreach ($availableServers as $index => $server) - @@ -380,10 +388,10 @@ class="p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:bo
@@ -398,11 +406,13 @@ class="text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:
@if ($loadingDestinations) -
- - +
+ + @@ -412,22 +422,25 @@ class="text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:
@elseif (count($availableDestinations) > 0) @foreach ($availableDestinations as $index => $destination) - @@ -449,10 +462,10 @@ class="p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:bo
@@ -467,11 +480,13 @@ class="text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:
@if ($loadingProjects) -
- - +
+ + @@ -481,15 +496,18 @@ class="text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:
@elseif (count($availableProjects) > 0) @foreach ($availableProjects as $index => $project) - @@ -524,10 +542,10 @@ class="p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:bo
@@ -542,11 +560,13 @@ class="text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:
@if ($loadingEnvironments) -
- - +
+ + @@ -556,15 +576,18 @@ class="text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:
@elseif (count($availableEnvironments) > 0) @foreach ($availableEnvironments as $index => $environment) - @@ -616,7 +639,8 @@ class="search-result-item block px-4 py-3 hover:bg-neutral-50 dark:hover:bg-cool
- + {{ $result['name'] }} +
{{ $result['project'] }} / {{ $result['environment'] }}
@endif @if (!empty($result['description'])) -
+
{{ Str::limit($result['description'], 80) }}
@endif @@ -651,8 +677,8 @@ class="px-2 py-0.5 text-xs rounded-full bg-neutral-100 dark:bg-coolgray-300 text - +
@@ -682,15 +708,16 @@ class="search-result-item w-full text-left block px-4 py-3 hover:bg-yellow-50 da
- + class="h-5 w-5 text-yellow-600 dark:text-yellow-400" + fill="none" viewBox="0 0 24 24" stroke="currentColor"> +
-
+
{{ $item['name'] }}
@if (isset($item['quickcommand'])) @@ -698,7 +725,8 @@ class="h-5 w-5 text-yellow-600 dark:text-yellow-400" fill="none" class="text-xs text-neutral-500 dark:text-neutral-400 shrink-0">{{ $item['quickcommand'] }} @endif
-
+
{{ $item['description'] }}
@@ -706,8 +734,8 @@ class="text-xs text-neutral-500 dark:text-neutral-400 shrink-0">{{ $item['quickc - +
@@ -792,7 +820,8 @@ class="search-result-item w-full text-left block px-4 py-3 hover:bg-yellow-50 da class="flex-shrink-0 w-10 h-10 rounded-lg bg-yellow-100 dark:bg-yellow-900/40 flex items-center justify-center"> + fill="none" viewBox="0 0 24 24" + stroke="currentColor"> @@ -860,10 +889,12 @@ class="shrink-0 h-5 w-5 text-yellow-500 dark:text-yellow-400 self-center" if (firstInput) firstInput.focus(); }, 200); } - })" class="fixed top-0 left-0 lg:px-0 px-4 z-99 flex items-center justify-center w-screen h-screen"> -
+
New Project @@ -900,10 +931,12 @@ class="absolute top-0 right-0 flex items-center justify-center w-8 h-8 mt-5 mr-5 if (firstInput) firstInput.focus(); }, 200); } - })" class="fixed top-0 left-0 lg:px-0 px-4 z-99 flex items-center justify-center w-screen h-screen"> -
+
New Server @@ -940,10 +973,12 @@ class="absolute top-0 right-0 flex items-center justify-center w-8 h-8 mt-5 mr-5 if (firstInput) firstInput.focus(); }, 200); } - })" class="fixed top-0 left-0 lg:px-0 px-4 z-99 flex items-center justify-center w-screen h-screen"> -
+
New Team @@ -980,10 +1015,12 @@ class="absolute top-0 right-0 flex items-center justify-center w-8 h-8 mt-5 mr-5 if (firstInput) firstInput.focus(); }, 200); } - })" class="fixed top-0 left-0 lg:px-0 px-4 z-99 flex items-center justify-center w-screen h-screen"> -
+
New S3 Storage @@ -1020,10 +1057,12 @@ class="absolute top-0 right-0 flex items-center justify-center w-8 h-8 mt-5 mr-5 if (firstInput) firstInput.focus(); }, 200); } - })" class="fixed top-0 left-0 lg:px-0 px-4 z-99 flex items-center justify-center w-screen h-screen"> -
+
New Private Key @@ -1060,10 +1099,12 @@ class="absolute top-0 right-0 flex items-center justify-center w-8 h-8 mt-5 mr-5 if (firstInput) firstInput.focus(); }, 200); } - })" class="fixed top-0 left-0 lg:px-0 px-4 z-99 flex items-center justify-center w-screen h-screen"> -
+
New GitHub App @@ -1090,4 +1131,4 @@ class="absolute top-0 right-0 flex items-center justify-center w-8 h-8 mt-5 mr-5
-
\ No newline at end of file +
diff --git a/tests/Unit/GlobalSearchNewImageQuickActionTest.php b/tests/Unit/GlobalSearchNewImageQuickActionTest.php new file mode 100644 index 000000000..4ef566ab3 --- /dev/null +++ b/tests/Unit/GlobalSearchNewImageQuickActionTest.php @@ -0,0 +1,44 @@ +toContain('item.quickcommand') + ->toContain('quickcommand.toLowerCase().includes(trimmed)'); +}); + +it('ensures GlobalSearch clears search query when starting resource creation', function () { + $globalSearchFile = file_get_contents(__DIR__.'/../../app/Livewire/GlobalSearch.php'); + + // Check that navigateToResourceCreation clears the search query + expect($globalSearchFile) + ->toContain('$this->searchQuery = \'\''); +}); + +it('ensures GlobalSearch uses Livewire redirect method', function () { + $globalSearchFile = file_get_contents(__DIR__.'/../../app/Livewire/GlobalSearch.php'); + + // Check that completeResourceCreation uses $this->redirect() + expect($globalSearchFile) + ->toContain('$this->redirect(route(\'project.resource.create\''); +}); + +it('ensures docker-image item has quickcommand with new image', function () { + $globalSearchFile = file_get_contents(__DIR__.'/../../app/Livewire/GlobalSearch.php'); + + // Check that Docker Image has the correct quickcommand + expect($globalSearchFile) + ->toContain("'name' => 'Docker Image'") + ->toContain("'quickcommand' => '(type: new image)'") + ->toContain("'type' => 'docker-image'"); +});