improvements of global search
This commit is contained in:
parent
0cddee6ead
commit
adf5bbd91a
2 changed files with 1215 additions and 141 deletions
|
|
@ -34,6 +34,35 @@ class GlobalSearch extends Component
|
|||
|
||||
public $autoOpenResource = null;
|
||||
|
||||
// Resource selection state
|
||||
public $isSelectingResource = false;
|
||||
|
||||
public $selectedResourceType = null;
|
||||
|
||||
public $loadingServers = false;
|
||||
|
||||
public $loadingProjects = false;
|
||||
|
||||
public $loadingEnvironments = false;
|
||||
|
||||
public $availableServers = [];
|
||||
|
||||
public $availableProjects = [];
|
||||
|
||||
public $availableEnvironments = [];
|
||||
|
||||
public $selectedServerId = null;
|
||||
|
||||
public $selectedDestinationUuid = null;
|
||||
|
||||
public $selectedProjectUuid = null;
|
||||
|
||||
public $selectedEnvironmentUuid = null;
|
||||
|
||||
public $availableDestinations = [];
|
||||
|
||||
public $loadingDestinations = false;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->searchQuery = '';
|
||||
|
|
@ -43,6 +72,7 @@ public function mount()
|
|||
$this->isCreateMode = false;
|
||||
$this->creatableItems = [];
|
||||
$this->autoOpenResource = null;
|
||||
$this->isSelectingResource = false;
|
||||
}
|
||||
|
||||
public function openSearchModal()
|
||||
|
|
@ -73,6 +103,9 @@ public function updatedSearchQuery()
|
|||
{
|
||||
$query = strtolower(trim($this->searchQuery));
|
||||
|
||||
// Reset keyboard navigation index
|
||||
$this->dispatch('reset-selected-index');
|
||||
|
||||
if (str_starts_with($query, 'new')) {
|
||||
$this->isCreateMode = true;
|
||||
$this->loadCreatableItems();
|
||||
|
|
@ -80,11 +113,18 @@ public function updatedSearchQuery()
|
|||
|
||||
// Check for sub-commands like "new project", "new server", etc.
|
||||
// Use original query (not trimmed) to ensure exact match without trailing spaces
|
||||
$this->autoOpenResource = $this->detectSpecificResource(strtolower($this->searchQuery));
|
||||
$detectedType = $this->detectSpecificResource(strtolower($this->searchQuery));
|
||||
if ($detectedType) {
|
||||
$this->navigateToResource($detectedType);
|
||||
} else {
|
||||
// If no specific resource detected, reset selection state
|
||||
$this->cancelResourceSelection();
|
||||
}
|
||||
} else {
|
||||
$this->isCreateMode = false;
|
||||
$this->creatableItems = [];
|
||||
$this->autoOpenResource = null;
|
||||
$this->isSelectingResource = false;
|
||||
$this->search();
|
||||
}
|
||||
}
|
||||
|
|
@ -93,6 +133,7 @@ private function detectSpecificResource(string $query): ?string
|
|||
{
|
||||
// Map of keywords to resource types - order matters for multi-word matches
|
||||
$resourceMap = [
|
||||
// Quick Actions
|
||||
'new project' => 'project',
|
||||
'new server' => 'server',
|
||||
'new team' => 'team',
|
||||
|
|
@ -101,9 +142,38 @@ private function detectSpecificResource(string $query): ?string
|
|||
'new private key' => 'private-key',
|
||||
'new privatekey' => 'private-key',
|
||||
'new key' => 'private-key',
|
||||
'new github app' => 'source',
|
||||
'new github' => 'source',
|
||||
'new source' => 'source',
|
||||
'new git' => 'source',
|
||||
|
||||
// Applications - Git-based
|
||||
'new public' => 'public',
|
||||
'new public git' => 'public',
|
||||
'new public repo' => 'public',
|
||||
'new public repository' => 'public',
|
||||
'new private github' => 'private-gh-app',
|
||||
'new private gh' => 'private-gh-app',
|
||||
'new private deploy' => 'private-deploy-key',
|
||||
'new deploy key' => 'private-deploy-key',
|
||||
|
||||
// Applications - Docker-based
|
||||
'new dockerfile' => 'dockerfile',
|
||||
'new docker compose' => 'docker-compose-empty',
|
||||
'new compose' => 'docker-compose-empty',
|
||||
'new docker image' => 'docker-image',
|
||||
'new image' => 'docker-image',
|
||||
|
||||
// Databases
|
||||
'new postgresql' => 'postgresql',
|
||||
'new postgres' => 'postgresql',
|
||||
'new mysql' => 'mysql',
|
||||
'new mariadb' => 'mariadb',
|
||||
'new redis' => 'redis',
|
||||
'new keydb' => 'keydb',
|
||||
'new dragonfly' => 'dragonfly',
|
||||
'new mongodb' => 'mongodb',
|
||||
'new mongo' => 'mongodb',
|
||||
'new clickhouse' => 'clickhouse',
|
||||
];
|
||||
|
||||
foreach ($resourceMap as $command => $type) {
|
||||
|
|
@ -122,12 +192,29 @@ private function canCreateResource(string $type): bool
|
|||
{
|
||||
$user = auth()->user();
|
||||
|
||||
return match ($type) {
|
||||
'project', 'source' => $user->can('createAnyResource'),
|
||||
'server', 'storage', 'private-key' => $user->isAdmin() || $user->isOwner(),
|
||||
'team' => true,
|
||||
default => false,
|
||||
};
|
||||
// Quick Actions
|
||||
if (in_array($type, ['server', 'storage', 'private-key'])) {
|
||||
return $user->isAdmin() || $user->isOwner();
|
||||
}
|
||||
|
||||
if ($type === 'team') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Applications, Databases, Services, and other resources
|
||||
if (in_array($type, [
|
||||
'project', 'source',
|
||||
// Applications
|
||||
'public', 'private-gh-app', 'private-deploy-key',
|
||||
'dockerfile', 'docker-compose-empty', 'docker-image',
|
||||
// Databases
|
||||
'postgresql', 'mysql', 'mariadb', 'redis', 'keydb',
|
||||
'dragonfly', 'mongodb', 'clickhouse',
|
||||
]) || str_starts_with($type, 'one-click-service-')) {
|
||||
return $user->can('createAnyResource');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function loadSearchableItems()
|
||||
|
|
@ -181,7 +268,7 @@ private function loadSearchableItems()
|
|||
'project' => $app->environment->project->name ?? null,
|
||||
'environment' => $app->environment->name ?? null,
|
||||
'fqdns' => $fqdns->take(2)->implode(', '), // Show first 2 FQDNs in UI
|
||||
'search_text' => strtolower($app->name.' '.$app->description.' '.$fqdnsString),
|
||||
'search_text' => strtolower($app->name.' '.$app->description.' '.$fqdnsString.' application applications app apps'),
|
||||
];
|
||||
});
|
||||
|
||||
|
|
@ -210,7 +297,7 @@ private function loadSearchableItems()
|
|||
'project' => $service->environment->project->name ?? null,
|
||||
'environment' => $service->environment->name ?? null,
|
||||
'fqdns' => $fqdns->take(2)->implode(', '), // Show first 2 FQDNs in UI
|
||||
'search_text' => strtolower($service->name.' '.$service->description.' '.$fqdnsString),
|
||||
'search_text' => strtolower($service->name.' '.$service->description.' '.$fqdnsString.' service services'),
|
||||
];
|
||||
});
|
||||
|
||||
|
|
@ -233,7 +320,7 @@ private function loadSearchableItems()
|
|||
'link' => $db->link(),
|
||||
'project' => $db->environment->project->name ?? null,
|
||||
'environment' => $db->environment->name ?? null,
|
||||
'search_text' => strtolower($db->name.' postgresql '.$db->description),
|
||||
'search_text' => strtolower($db->name.' postgresql '.$db->description.' database databases db'),
|
||||
];
|
||||
})
|
||||
);
|
||||
|
|
@ -254,7 +341,7 @@ private function loadSearchableItems()
|
|||
'link' => $db->link(),
|
||||
'project' => $db->environment->project->name ?? null,
|
||||
'environment' => $db->environment->name ?? null,
|
||||
'search_text' => strtolower($db->name.' mysql '.$db->description),
|
||||
'search_text' => strtolower($db->name.' mysql '.$db->description.' database databases db'),
|
||||
];
|
||||
})
|
||||
);
|
||||
|
|
@ -275,7 +362,7 @@ private function loadSearchableItems()
|
|||
'link' => $db->link(),
|
||||
'project' => $db->environment->project->name ?? null,
|
||||
'environment' => $db->environment->name ?? null,
|
||||
'search_text' => strtolower($db->name.' mariadb '.$db->description),
|
||||
'search_text' => strtolower($db->name.' mariadb '.$db->description.' database databases db'),
|
||||
];
|
||||
})
|
||||
);
|
||||
|
|
@ -296,7 +383,7 @@ private function loadSearchableItems()
|
|||
'link' => $db->link(),
|
||||
'project' => $db->environment->project->name ?? null,
|
||||
'environment' => $db->environment->name ?? null,
|
||||
'search_text' => strtolower($db->name.' mongodb '.$db->description),
|
||||
'search_text' => strtolower($db->name.' mongodb '.$db->description.' database databases db'),
|
||||
];
|
||||
})
|
||||
);
|
||||
|
|
@ -317,7 +404,7 @@ private function loadSearchableItems()
|
|||
'link' => $db->link(),
|
||||
'project' => $db->environment->project->name ?? null,
|
||||
'environment' => $db->environment->name ?? null,
|
||||
'search_text' => strtolower($db->name.' redis '.$db->description),
|
||||
'search_text' => strtolower($db->name.' redis '.$db->description.' database databases db'),
|
||||
];
|
||||
})
|
||||
);
|
||||
|
|
@ -338,7 +425,7 @@ private function loadSearchableItems()
|
|||
'link' => $db->link(),
|
||||
'project' => $db->environment->project->name ?? null,
|
||||
'environment' => $db->environment->name ?? null,
|
||||
'search_text' => strtolower($db->name.' keydb '.$db->description),
|
||||
'search_text' => strtolower($db->name.' keydb '.$db->description.' database databases db'),
|
||||
];
|
||||
})
|
||||
);
|
||||
|
|
@ -359,7 +446,7 @@ private function loadSearchableItems()
|
|||
'link' => $db->link(),
|
||||
'project' => $db->environment->project->name ?? null,
|
||||
'environment' => $db->environment->name ?? null,
|
||||
'search_text' => strtolower($db->name.' dragonfly '.$db->description),
|
||||
'search_text' => strtolower($db->name.' dragonfly '.$db->description.' database databases db'),
|
||||
];
|
||||
})
|
||||
);
|
||||
|
|
@ -380,7 +467,7 @@ private function loadSearchableItems()
|
|||
'link' => $db->link(),
|
||||
'project' => $db->environment->project->name ?? null,
|
||||
'environment' => $db->environment->name ?? null,
|
||||
'search_text' => strtolower($db->name.' clickhouse '.$db->description),
|
||||
'search_text' => strtolower($db->name.' clickhouse '.$db->description.' database databases db'),
|
||||
];
|
||||
})
|
||||
);
|
||||
|
|
@ -398,10 +485,10 @@ private function loadSearchableItems()
|
|||
'link' => $server->url(),
|
||||
'project' => null,
|
||||
'environment' => null,
|
||||
'search_text' => strtolower($server->name.' '.$server->ip.' '.$server->description),
|
||||
'search_text' => strtolower($server->name.' '.$server->ip.' '.$server->description.' server servers'),
|
||||
];
|
||||
});
|
||||
|
||||
ray($servers);
|
||||
// Get all projects
|
||||
$projects = Project::ownedByCurrentTeam()
|
||||
->withCount(['environments', 'applications', 'services'])
|
||||
|
|
@ -423,7 +510,7 @@ private function loadSearchableItems()
|
|||
'environment' => null,
|
||||
'resource_count' => $resourceSummary,
|
||||
'environment_count' => $project->environments_count,
|
||||
'search_text' => strtolower($project->name.' '.$project->description.' project'),
|
||||
'search_text' => strtolower($project->name.' '.$project->description.' project projects'),
|
||||
];
|
||||
});
|
||||
|
||||
|
|
@ -484,7 +571,7 @@ private function loadSearchableItems()
|
|||
|
||||
private function search()
|
||||
{
|
||||
if (strlen($this->searchQuery) < 2) {
|
||||
if (strlen($this->searchQuery) < 1) {
|
||||
$this->searchResults = [];
|
||||
|
||||
return;
|
||||
|
|
@ -492,14 +579,126 @@ private function search()
|
|||
|
||||
$query = strtolower($this->searchQuery);
|
||||
|
||||
// Case-insensitive search in the items
|
||||
$this->searchResults = collect($this->allSearchableItems)
|
||||
// Detect resource category queries
|
||||
$categoryMapping = [
|
||||
'server' => ['server', 'type' => 'server'],
|
||||
'servers' => ['server', 'type' => 'server'],
|
||||
'app' => ['application', 'type' => 'application'],
|
||||
'apps' => ['application', 'type' => 'application'],
|
||||
'application' => ['application', 'type' => 'application'],
|
||||
'applications' => ['application', 'type' => 'application'],
|
||||
'db' => ['database', 'type' => 'standalone-postgresql'],
|
||||
'database' => ['database', 'type' => 'standalone-postgresql'],
|
||||
'databases' => ['database', 'type' => 'standalone-postgresql'],
|
||||
'service' => ['service', 'category' => 'Services'],
|
||||
'services' => ['service', 'category' => 'Services'],
|
||||
'project' => ['project', 'type' => 'project'],
|
||||
'projects' => ['project', 'type' => 'project'],
|
||||
];
|
||||
|
||||
$priorityCreatableItem = null;
|
||||
|
||||
// Check if query matches a resource category
|
||||
if (isset($categoryMapping[$query])) {
|
||||
$this->loadCreatableItems();
|
||||
$mapping = $categoryMapping[$query];
|
||||
|
||||
// Find the matching creatable item
|
||||
$priorityCreatableItem = collect($this->creatableItems)
|
||||
->first(function ($item) use ($mapping) {
|
||||
if (isset($mapping['type'])) {
|
||||
return $item['type'] === $mapping['type'];
|
||||
}
|
||||
if (isset($mapping['category'])) {
|
||||
return isset($item['category']) && $item['category'] === $mapping['category'];
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if ($priorityCreatableItem) {
|
||||
$priorityCreatableItem['is_creatable_suggestion'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Search for matching creatable resources to show as suggestions (if no priority item)
|
||||
if (! $priorityCreatableItem) {
|
||||
$this->loadCreatableItems();
|
||||
$creatableSuggestions = collect($this->creatableItems)
|
||||
->filter(function ($item) use ($query) {
|
||||
$searchText = strtolower($item['name'].' '.$item['description'].' '.($item['type'] ?? ''));
|
||||
|
||||
// Use word boundary matching to avoid substring matches (e.g., "wordpress" shouldn't match "classicpress")
|
||||
return preg_match('/\b'.preg_quote($query, '/').'/i', $searchText);
|
||||
})
|
||||
->map(function ($item) use ($query) {
|
||||
// Calculate match priority: name > type > description
|
||||
$name = strtolower($item['name']);
|
||||
$type = strtolower($item['type'] ?? '');
|
||||
$description = strtolower($item['description']);
|
||||
|
||||
if (preg_match('/\b'.preg_quote($query, '/').'/i', $name)) {
|
||||
$item['match_priority'] = 1;
|
||||
} elseif (preg_match('/\b'.preg_quote($query, '/').'/i', $type)) {
|
||||
$item['match_priority'] = 2;
|
||||
} else {
|
||||
$item['match_priority'] = 3;
|
||||
}
|
||||
|
||||
$item['is_creatable_suggestion'] = true;
|
||||
|
||||
return $item;
|
||||
})
|
||||
->sortBy('match_priority')
|
||||
->take(10)
|
||||
->values()
|
||||
->toArray();
|
||||
} else {
|
||||
$creatableSuggestions = [];
|
||||
}
|
||||
|
||||
// Case-insensitive search in existing resources
|
||||
$existingResults = collect($this->allSearchableItems)
|
||||
->filter(function ($item) use ($query) {
|
||||
return str_contains($item['search_text'], $query);
|
||||
// Use word boundary matching to avoid substring matches (e.g., "wordpress" shouldn't match "classicpress")
|
||||
return preg_match('/\b'.preg_quote($query, '/').'/i', $item['search_text']);
|
||||
})
|
||||
->map(function ($item) use ($query) {
|
||||
// Calculate match priority: name > type > description
|
||||
$name = strtolower($item['name'] ?? '');
|
||||
$type = strtolower($item['type'] ?? '');
|
||||
$description = strtolower($item['description'] ?? '');
|
||||
|
||||
if (preg_match('/\b'.preg_quote($query, '/').'/i', $name)) {
|
||||
$item['match_priority'] = 1;
|
||||
} elseif (preg_match('/\b'.preg_quote($query, '/').'/i', $type)) {
|
||||
$item['match_priority'] = 2;
|
||||
} else {
|
||||
$item['match_priority'] = 3;
|
||||
}
|
||||
|
||||
return $item;
|
||||
})
|
||||
->sortBy('match_priority')
|
||||
->take(20)
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
// Merge results: existing resources first, then priority create item, then other creatable suggestions
|
||||
$results = [];
|
||||
|
||||
// If we have existing results, show them first
|
||||
$results = array_merge($results, $existingResults);
|
||||
|
||||
// Then show the priority "Create New" item (if exists)
|
||||
if ($priorityCreatableItem) {
|
||||
$results[] = $priorityCreatableItem;
|
||||
}
|
||||
|
||||
// Finally show other creatable suggestions
|
||||
$results = array_merge($results, $creatableSuggestions);
|
||||
|
||||
$this->searchResults = $results;
|
||||
}
|
||||
|
||||
private function loadCreatableItems()
|
||||
|
|
@ -507,12 +706,16 @@ private function loadCreatableItems()
|
|||
$items = collect();
|
||||
$user = auth()->user();
|
||||
|
||||
// === Quick Actions Category ===
|
||||
|
||||
// Project - can be created if user has createAnyResource permission
|
||||
if ($user->can('createAnyResource')) {
|
||||
$items->push([
|
||||
'name' => 'Project',
|
||||
'description' => 'Create a new project to organize your resources',
|
||||
'quickcommand' => '(type: new project)',
|
||||
'type' => 'project',
|
||||
'category' => 'Quick Actions',
|
||||
'component' => 'project.add-empty',
|
||||
]);
|
||||
}
|
||||
|
|
@ -522,7 +725,9 @@ private function loadCreatableItems()
|
|||
$items->push([
|
||||
'name' => 'Server',
|
||||
'description' => 'Add a new server to deploy your applications',
|
||||
'quickcommand' => '(type: new server)',
|
||||
'type' => 'server',
|
||||
'category' => 'Quick Actions',
|
||||
'component' => 'server.create',
|
||||
]);
|
||||
}
|
||||
|
|
@ -531,7 +736,9 @@ private function loadCreatableItems()
|
|||
$items->push([
|
||||
'name' => 'Team',
|
||||
'description' => 'Create a new team to collaborate with others',
|
||||
'quickcommand' => '(type: new team)',
|
||||
'type' => 'team',
|
||||
'category' => 'Quick Actions',
|
||||
'component' => 'team.create',
|
||||
]);
|
||||
|
||||
|
|
@ -540,7 +747,9 @@ private function loadCreatableItems()
|
|||
$items->push([
|
||||
'name' => 'S3 Storage',
|
||||
'description' => 'Add S3 storage for backups and file uploads',
|
||||
'quickcommand' => '(type: new storage)',
|
||||
'type' => 'storage',
|
||||
'category' => 'Quick Actions',
|
||||
'component' => 'storage.create',
|
||||
]);
|
||||
}
|
||||
|
|
@ -550,7 +759,9 @@ private function loadCreatableItems()
|
|||
$items->push([
|
||||
'name' => 'Private Key',
|
||||
'description' => 'Add an SSH private key for server access',
|
||||
'quickcommand' => '(type: new private key)',
|
||||
'type' => 'private-key',
|
||||
'category' => 'Quick Actions',
|
||||
'component' => 'security.private-key.create',
|
||||
]);
|
||||
}
|
||||
|
|
@ -560,14 +771,468 @@ private function loadCreatableItems()
|
|||
$items->push([
|
||||
'name' => 'GitHub App',
|
||||
'description' => 'Connect a GitHub app for source control',
|
||||
'quickcommand' => '(type: new github)',
|
||||
'type' => 'source',
|
||||
'category' => 'Quick Actions',
|
||||
'component' => 'source.github.create',
|
||||
]);
|
||||
}
|
||||
|
||||
// === Applications Category ===
|
||||
|
||||
if ($user->can('createAnyResource')) {
|
||||
// Git-based applications
|
||||
$items->push([
|
||||
'name' => 'Public Git Repository',
|
||||
'description' => 'Deploy from any public Git repository',
|
||||
'quickcommand' => '(type: new public)',
|
||||
'type' => 'public',
|
||||
'category' => 'Applications',
|
||||
'resourceType' => 'application',
|
||||
]);
|
||||
|
||||
$items->push([
|
||||
'name' => 'Private Repository (GitHub App)',
|
||||
'description' => 'Deploy private repositories through GitHub Apps',
|
||||
'quickcommand' => '(type: new private github)',
|
||||
'type' => 'private-gh-app',
|
||||
'category' => 'Applications',
|
||||
'resourceType' => 'application',
|
||||
]);
|
||||
|
||||
$items->push([
|
||||
'name' => 'Private Repository (Deploy Key)',
|
||||
'description' => 'Deploy private repositories with a deploy key',
|
||||
'quickcommand' => '(type: new private deploy)',
|
||||
'type' => 'private-deploy-key',
|
||||
'category' => 'Applications',
|
||||
'resourceType' => 'application',
|
||||
]);
|
||||
|
||||
// Docker-based applications
|
||||
$items->push([
|
||||
'name' => 'Dockerfile',
|
||||
'description' => 'Deploy a simple Dockerfile without Git',
|
||||
'quickcommand' => '(type: new dockerfile)',
|
||||
'type' => 'dockerfile',
|
||||
'category' => 'Applications',
|
||||
'resourceType' => 'application',
|
||||
]);
|
||||
|
||||
$items->push([
|
||||
'name' => 'Docker Compose',
|
||||
'description' => 'Deploy complex applications with Docker Compose',
|
||||
'quickcommand' => '(type: new compose)',
|
||||
'type' => 'docker-compose-empty',
|
||||
'category' => 'Applications',
|
||||
'resourceType' => 'application',
|
||||
]);
|
||||
|
||||
$items->push([
|
||||
'name' => 'Docker Image',
|
||||
'description' => 'Deploy an existing Docker image from any registry',
|
||||
'quickcommand' => '(type: new image)',
|
||||
'type' => 'docker-image',
|
||||
'category' => 'Applications',
|
||||
'resourceType' => 'application',
|
||||
]);
|
||||
}
|
||||
|
||||
// === Databases Category ===
|
||||
|
||||
if ($user->can('createAnyResource')) {
|
||||
$items->push([
|
||||
'name' => 'PostgreSQL',
|
||||
'description' => 'Robust, advanced open-source database',
|
||||
'quickcommand' => '(type: new postgresql)',
|
||||
'type' => 'postgresql',
|
||||
'category' => 'Databases',
|
||||
'resourceType' => 'database',
|
||||
]);
|
||||
|
||||
$items->push([
|
||||
'name' => 'MySQL',
|
||||
'description' => 'Popular open-source relational database',
|
||||
'quickcommand' => '(type: new mysql)',
|
||||
'type' => 'mysql',
|
||||
'category' => 'Databases',
|
||||
'resourceType' => 'database',
|
||||
]);
|
||||
|
||||
$items->push([
|
||||
'name' => 'MariaDB',
|
||||
'description' => 'Community-developed fork of MySQL',
|
||||
'quickcommand' => '(type: new mariadb)',
|
||||
'type' => 'mariadb',
|
||||
'category' => 'Databases',
|
||||
'resourceType' => 'database',
|
||||
]);
|
||||
|
||||
$items->push([
|
||||
'name' => 'Redis',
|
||||
'description' => 'In-memory data structure store',
|
||||
'quickcommand' => '(type: new redis)',
|
||||
'type' => 'redis',
|
||||
'category' => 'Databases',
|
||||
'resourceType' => 'database',
|
||||
]);
|
||||
|
||||
$items->push([
|
||||
'name' => 'KeyDB',
|
||||
'description' => 'High-performance Redis alternative',
|
||||
'quickcommand' => '(type: new keydb)',
|
||||
'type' => 'keydb',
|
||||
'category' => 'Databases',
|
||||
'resourceType' => 'database',
|
||||
]);
|
||||
|
||||
$items->push([
|
||||
'name' => 'Dragonfly',
|
||||
'description' => 'Modern in-memory datastore',
|
||||
'quickcommand' => '(type: new dragonfly)',
|
||||
'type' => 'dragonfly',
|
||||
'category' => 'Databases',
|
||||
'resourceType' => 'database',
|
||||
]);
|
||||
|
||||
$items->push([
|
||||
'name' => 'MongoDB',
|
||||
'description' => 'Document-oriented NoSQL database',
|
||||
'quickcommand' => '(type: new mongodb)',
|
||||
'type' => 'mongodb',
|
||||
'category' => 'Databases',
|
||||
'resourceType' => 'database',
|
||||
]);
|
||||
|
||||
$items->push([
|
||||
'name' => 'Clickhouse',
|
||||
'description' => 'Column-oriented database for analytics',
|
||||
'quickcommand' => '(type: new clickhouse)',
|
||||
'type' => 'clickhouse',
|
||||
'category' => 'Databases',
|
||||
'resourceType' => 'database',
|
||||
]);
|
||||
}
|
||||
|
||||
// === Services Category ===
|
||||
|
||||
if ($user->can('createAnyResource')) {
|
||||
// Load all services
|
||||
$allServices = get_service_templates();
|
||||
|
||||
foreach ($allServices as $serviceKey => $service) {
|
||||
$items->push([
|
||||
'name' => str($serviceKey)->headline()->toString(),
|
||||
'description' => data_get($service, 'slogan', 'Deploy '.str($serviceKey)->headline()),
|
||||
'type' => 'one-click-service-'.$serviceKey,
|
||||
'category' => 'Services',
|
||||
'resourceType' => 'service',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->creatableItems = $items->toArray();
|
||||
}
|
||||
|
||||
public function navigateToResource($type)
|
||||
{
|
||||
// Find the item by type
|
||||
$item = collect($this->creatableItems)->firstWhere('type', $type);
|
||||
|
||||
if (! $item) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If it has a component, it's a modal-based resource
|
||||
// Close search modal and open the appropriate creation modal
|
||||
if (isset($item['component'])) {
|
||||
$this->dispatch('closeSearchModal');
|
||||
$this->dispatch('open-create-modal-'.$type);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// For applications, databases, and services, navigate to resource creation
|
||||
// with smart defaults (auto-select if only 1 server/project/environment)
|
||||
if (isset($item['resourceType'])) {
|
||||
$this->navigateToResourceCreation($type);
|
||||
}
|
||||
}
|
||||
|
||||
private function navigateToResourceCreation($type)
|
||||
{
|
||||
// Start the selection flow
|
||||
$this->selectedResourceType = $type;
|
||||
$this->isSelectingResource = true;
|
||||
|
||||
// Reset selections
|
||||
$this->selectedServerId = null;
|
||||
$this->selectedDestinationUuid = null;
|
||||
$this->selectedProjectUuid = null;
|
||||
$this->selectedEnvironmentUuid = null;
|
||||
|
||||
// Start loading servers first (in order: servers -> destinations -> projects -> environments)
|
||||
$this->loadServers();
|
||||
}
|
||||
|
||||
public function loadServers()
|
||||
{
|
||||
$this->loadingServers = true;
|
||||
$servers = Server::isUsable()->get()->sortBy('name');
|
||||
$this->availableServers = $servers->map(fn ($s) => [
|
||||
'id' => $s->id,
|
||||
'name' => $s->name,
|
||||
'description' => $s->description,
|
||||
])->toArray();
|
||||
$this->loadingServers = false;
|
||||
|
||||
// Auto-select if only one server
|
||||
if (count($this->availableServers) === 1) {
|
||||
$this->selectServer($this->availableServers[0]['id']);
|
||||
}
|
||||
}
|
||||
|
||||
public function selectServer($serverId, $shouldProgress = true)
|
||||
{
|
||||
$this->selectedServerId = $serverId;
|
||||
|
||||
if ($shouldProgress) {
|
||||
$this->loadDestinations();
|
||||
}
|
||||
}
|
||||
|
||||
public function loadDestinations()
|
||||
{
|
||||
$this->loadingDestinations = true;
|
||||
$server = Server::find($this->selectedServerId);
|
||||
|
||||
if (! $server) {
|
||||
$this->loadingDestinations = false;
|
||||
|
||||
return $this->dispatch('error', message: 'Server not found');
|
||||
}
|
||||
|
||||
$destinations = $server->destinations();
|
||||
|
||||
if ($destinations->isEmpty()) {
|
||||
$this->loadingDestinations = false;
|
||||
|
||||
return $this->dispatch('error', message: 'No destinations found on this server');
|
||||
}
|
||||
|
||||
$this->availableDestinations = $destinations->map(fn ($d) => [
|
||||
'uuid' => $d->uuid,
|
||||
'name' => $d->name,
|
||||
'network' => $d->network ?? 'default',
|
||||
])->toArray();
|
||||
|
||||
$this->loadingDestinations = false;
|
||||
|
||||
// Auto-select if only one destination
|
||||
if (count($this->availableDestinations) === 1) {
|
||||
$this->selectDestination($this->availableDestinations[0]['uuid']);
|
||||
}
|
||||
}
|
||||
|
||||
public function selectDestination($destinationUuid, $shouldProgress = true)
|
||||
{
|
||||
$this->selectedDestinationUuid = $destinationUuid;
|
||||
|
||||
if ($shouldProgress) {
|
||||
$this->loadProjects();
|
||||
}
|
||||
}
|
||||
|
||||
public function loadProjects()
|
||||
{
|
||||
$this->loadingProjects = true;
|
||||
$user = auth()->user();
|
||||
$team = $user->currentTeam();
|
||||
$projects = Project::where('team_id', $team->id)->get();
|
||||
|
||||
if ($projects->isEmpty()) {
|
||||
$this->loadingProjects = false;
|
||||
|
||||
return $this->dispatch('error', message: 'Please create a project first');
|
||||
}
|
||||
|
||||
$this->availableProjects = $projects->map(fn ($p) => [
|
||||
'uuid' => $p->uuid,
|
||||
'name' => $p->name,
|
||||
'description' => $p->description,
|
||||
])->toArray();
|
||||
$this->loadingProjects = false;
|
||||
|
||||
// Auto-select if only one project
|
||||
if (count($this->availableProjects) === 1) {
|
||||
$this->selectProject($this->availableProjects[0]['uuid']);
|
||||
}
|
||||
}
|
||||
|
||||
public function selectProject($projectUuid, $shouldProgress = true)
|
||||
{
|
||||
$this->selectedProjectUuid = $projectUuid;
|
||||
|
||||
if ($shouldProgress) {
|
||||
$this->loadEnvironments();
|
||||
}
|
||||
}
|
||||
|
||||
public function loadEnvironments()
|
||||
{
|
||||
$this->loadingEnvironments = true;
|
||||
$project = Project::where('uuid', $this->selectedProjectUuid)->first();
|
||||
|
||||
if (! $project) {
|
||||
$this->loadingEnvironments = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$environments = $project->environments;
|
||||
|
||||
if ($environments->isEmpty()) {
|
||||
$this->loadingEnvironments = false;
|
||||
|
||||
return $this->dispatch('error', message: 'No environments found in project');
|
||||
}
|
||||
|
||||
$this->availableEnvironments = $environments->map(fn ($e) => [
|
||||
'uuid' => $e->uuid,
|
||||
'name' => $e->name,
|
||||
'description' => $e->description,
|
||||
])->toArray();
|
||||
$this->loadingEnvironments = false;
|
||||
|
||||
// Auto-select if only one environment
|
||||
if (count($this->availableEnvironments) === 1) {
|
||||
$this->selectEnvironment($this->availableEnvironments[0]['uuid']);
|
||||
}
|
||||
}
|
||||
|
||||
public function selectEnvironment($environmentUuid, $shouldProgress = true)
|
||||
{
|
||||
$this->selectedEnvironmentUuid = $environmentUuid;
|
||||
|
||||
if ($shouldProgress) {
|
||||
$this->completeResourceCreation();
|
||||
}
|
||||
}
|
||||
|
||||
private function completeResourceCreation()
|
||||
{
|
||||
// All selections made - navigate to resource creation
|
||||
if ($this->selectedProjectUuid && $this->selectedEnvironmentUuid && $this->selectedResourceType && $this->selectedServerId !== null && $this->selectedDestinationUuid) {
|
||||
$queryParams = [
|
||||
'type' => $this->selectedResourceType,
|
||||
'destination' => $this->selectedDestinationUuid,
|
||||
'server_id' => $this->selectedServerId,
|
||||
];
|
||||
|
||||
// PostgreSQL requires a database_image parameter
|
||||
if ($this->selectedResourceType === 'postgresql') {
|
||||
$queryParams['database_image'] = 'postgres:16-alpine';
|
||||
}
|
||||
|
||||
return redirect()->route('project.resource.create', [
|
||||
'project_uuid' => $this->selectedProjectUuid,
|
||||
'environment_uuid' => $this->selectedEnvironmentUuid,
|
||||
] + $queryParams);
|
||||
}
|
||||
}
|
||||
|
||||
public function cancelResourceSelection()
|
||||
{
|
||||
$this->isSelectingResource = false;
|
||||
$this->selectedResourceType = null;
|
||||
$this->selectedServerId = null;
|
||||
$this->selectedDestinationUuid = null;
|
||||
$this->selectedProjectUuid = null;
|
||||
$this->selectedEnvironmentUuid = null;
|
||||
$this->availableServers = [];
|
||||
$this->availableDestinations = [];
|
||||
$this->availableProjects = [];
|
||||
$this->availableEnvironments = [];
|
||||
$this->autoOpenResource = null;
|
||||
}
|
||||
|
||||
public function getFilteredCreatableItemsProperty()
|
||||
{
|
||||
$query = strtolower(trim($this->searchQuery));
|
||||
|
||||
// Check if query matches a category keyword
|
||||
$categoryKeywords = ['server', 'servers', 'app', 'apps', 'application', 'applications', 'db', 'database', 'databases', 'service', 'services', 'project', 'projects'];
|
||||
if (in_array($query, $categoryKeywords)) {
|
||||
return $this->filterCreatableItemsByCategory($query);
|
||||
}
|
||||
|
||||
// Extract search term - everything after "new "
|
||||
if (str_starts_with($query, 'new ')) {
|
||||
$searchTerm = trim(substr($query, strlen('new ')));
|
||||
|
||||
if (empty($searchTerm)) {
|
||||
return $this->creatableItems;
|
||||
}
|
||||
|
||||
// Filter items by name or description
|
||||
return collect($this->creatableItems)->filter(function ($item) use ($searchTerm) {
|
||||
$searchText = strtolower($item['name'].' '.$item['description'].' '.$item['category']);
|
||||
|
||||
return str_contains($searchText, $searchTerm);
|
||||
})->values()->toArray();
|
||||
}
|
||||
|
||||
return $this->creatableItems;
|
||||
}
|
||||
|
||||
private function filterCreatableItemsByCategory($categoryKeyword)
|
||||
{
|
||||
// Map keywords to category names
|
||||
$categoryMap = [
|
||||
'server' => 'Quick Actions',
|
||||
'servers' => 'Quick Actions',
|
||||
'app' => 'Applications',
|
||||
'apps' => 'Applications',
|
||||
'application' => 'Applications',
|
||||
'applications' => 'Applications',
|
||||
'db' => 'Databases',
|
||||
'database' => 'Databases',
|
||||
'databases' => 'Databases',
|
||||
'service' => 'Services',
|
||||
'services' => 'Services',
|
||||
'project' => 'Applications',
|
||||
'projects' => 'Applications',
|
||||
];
|
||||
|
||||
$category = $categoryMap[$categoryKeyword] ?? null;
|
||||
|
||||
if (! $category) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return collect($this->creatableItems)
|
||||
->filter(fn ($item) => $item['category'] === $category)
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function getSelectedResourceNameProperty()
|
||||
{
|
||||
if (! $this->selectedResourceType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Load creatable items if not loaded yet
|
||||
if (empty($this->creatableItems)) {
|
||||
$this->loadCreatableItems();
|
||||
}
|
||||
|
||||
// Find the item by type
|
||||
$item = collect($this->creatableItems)->firstWhere('type', $this->selectedResourceType);
|
||||
|
||||
return $item ? $item['name'] : null;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.global-search');
|
||||
|
|
|
|||
|
|
@ -31,27 +31,60 @@
|
|||
}
|
||||
},
|
||||
init() {
|
||||
// Listen for reset index event from Livewire
|
||||
Livewire.on('reset-selected-index', () => {
|
||||
this.selectedIndex = -1;
|
||||
});
|
||||
|
||||
// Create named handlers for proper cleanup
|
||||
const openGlobalSearchHandler = () => this.openModal();
|
||||
const slashKeyHandler = (e) => {
|
||||
if (e.key === '/' && !['INPUT', 'TEXTAREA'].includes(e.target.tagName) && !this.modalOpen) {
|
||||
if (e.key === '/' && !['INPUT', 'TEXTAREA'].includes(e.target.tagName)) {
|
||||
e.preventDefault();
|
||||
this.openModal();
|
||||
if (!this.modalOpen) {
|
||||
this.openModal();
|
||||
} else {
|
||||
// If modal is open, focus the input
|
||||
this.$refs.searchInput?.focus();
|
||||
this.selectedIndex = -1;
|
||||
}
|
||||
}
|
||||
};
|
||||
const cmdKHandler = (e) => {
|
||||
if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (this.modalOpen) {
|
||||
this.closeModal();
|
||||
// If modal is open, focus the input instead of closing
|
||||
this.$refs.searchInput?.focus();
|
||||
this.selectedIndex = -1;
|
||||
} else {
|
||||
this.openModal();
|
||||
}
|
||||
}
|
||||
};
|
||||
const escapeKeyHandler = (e) => {
|
||||
const escapeKeyHandler = async (e) => {
|
||||
if (e.key === 'Escape' && this.modalOpen) {
|
||||
this.closeModal();
|
||||
// If search query is empty, close the modal
|
||||
const searchQuery = await @this.get('searchQuery');
|
||||
if (searchQuery === '') {
|
||||
// Check if we're in a selection state - go back to main menu first
|
||||
const selectingServer = await @this.get('selectingServer');
|
||||
const selectingProject = await @this.get('selectingProject');
|
||||
const selectingEnvironment = await @this.get('selectingEnvironment');
|
||||
const selectingDestination = await @this.get('selectingDestination');
|
||||
|
||||
if (selectingServer || selectingProject || selectingEnvironment || selectingDestination) {
|
||||
@this.call('cancelResourceSelection');
|
||||
setTimeout(() => this.$refs.searchInput?.focus(), 100);
|
||||
} else {
|
||||
// Close the modal if in main menu
|
||||
this.closeModal();
|
||||
}
|
||||
} else {
|
||||
// If search query has text, just clear it
|
||||
@this.set('searchQuery', '');
|
||||
setTimeout(() => this.$refs.searchInput?.focus(), 100);
|
||||
}
|
||||
}
|
||||
};
|
||||
const arrowKeyHandler = (e) => {
|
||||
|
|
@ -94,13 +127,18 @@
|
|||
}, 150);
|
||||
}
|
||||
});
|
||||
|
||||
// Listen for closeSearchModal event from backend
|
||||
window.addEventListener('closeSearchModal', () => {
|
||||
this.closeModal();
|
||||
});
|
||||
}
|
||||
}">
|
||||
|
||||
<!-- Modal overlay -->
|
||||
<template x-teleport="body">
|
||||
<div x-show="modalOpen" x-cloak
|
||||
class="fixed top-0 left-0 z-99 flex items-start justify-center w-screen h-screen pt-[20vh]">
|
||||
class="fixed top-0 left-0 z-99 flex items-start justify-center w-screen h-screen pt-[10vh]">
|
||||
<div @click="closeModal()" class="absolute inset-0 w-full h-full bg-black/50 backdrop-blur-sm">
|
||||
</div>
|
||||
<div x-show="modalOpen" x-trap.inert="modalOpen" x-init="$watch('modalOpen', value => { document.body.style.overflow = value ? 'hidden' : '' })"
|
||||
|
|
@ -119,14 +157,19 @@ class="fixed top-0 left-0 z-99 flex items-start justify-center w-screen h-screen
|
|||
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
||||
</svg>
|
||||
</div>
|
||||
<input type="text" wire:model.live.debounce.500ms="searchQuery"
|
||||
placeholder="Search for resources... (Type 'new' to create, or 'new project' to add directly)"
|
||||
x-ref="searchInput" x-init="$watch('modalOpen', value => { if (value) setTimeout(() => $refs.searchInput.focus(), 100) })"
|
||||
class="w-full pl-12 pr-12 py-4 text-base bg-white dark:bg-coolgray-100 border-none rounded-lg shadow-xl ring-1 ring-neutral-200 dark:ring-coolgray-300 focus:ring-2 focus:ring-neutral-400 dark:focus:ring-coolgray-300 dark:text-white placeholder-neutral-400 dark:placeholder-neutral-500" />
|
||||
<button @click="closeModal()"
|
||||
class="absolute inset-y-0 right-2 flex items-center justify-center px-2 text-xs font-medium text-neutral-500 dark:text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200 rounded">
|
||||
ESC
|
||||
</button>
|
||||
<input type="text" wire:model.live.debounce.200ms="searchQuery"
|
||||
placeholder="Search resources (type new for create things)..." x-ref="searchInput"
|
||||
x-init="$watch('modalOpen', value => { if (value) setTimeout(() => $refs.searchInput.focus(), 100) })"
|
||||
class="w-full pl-12 pr-32 py-4 text-base bg-white dark:bg-coolgray-100 border-none rounded-lg shadow-xl ring-1 ring-neutral-200 dark:ring-coolgray-300 focus:ring-2 focus:ring-neutral-400 dark:focus:ring-coolgray-300 dark:text-white placeholder-neutral-400 dark:placeholder-neutral-500" />
|
||||
<div class="absolute inset-y-0 right-2 flex items-center gap-2 pointer-events-none">
|
||||
<span class="text-xs font-medium text-neutral-400 dark:text-neutral-500">
|
||||
/ or ⌘K to focus
|
||||
</span>
|
||||
<button @click="closeModal()"
|
||||
class="pointer-events-auto px-2 py-1 text-xs font-medium text-neutral-500 dark:text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200 rounded">
|
||||
ESC
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Search results (with background) -->
|
||||
|
|
@ -154,22 +197,326 @@ class="min-h-[200px] items-center justify-center p-8">
|
|||
<!-- Results content - hidden while loading -->
|
||||
<div wire:loading.remove wire:target="searchQuery"
|
||||
class="max-h-[60vh] overflow-y-auto scrollbar">
|
||||
@if ($isCreateMode && count($creatableItems) > 0 && !$autoOpenResource)
|
||||
@if ($isSelectingResource)
|
||||
<!-- Resource Selection Flow -->
|
||||
<div class="p-6">
|
||||
<!-- Server Selection -->
|
||||
@if ($selectedServerId === null)
|
||||
<div class="mb-4" x-init="selectedIndex = -1">
|
||||
<div class="flex items-center gap-3 mb-3">
|
||||
<button type="button"
|
||||
@click="$wire.set('searchQuery', ''); setTimeout(() => $refs.searchInput.focus(), 100)"
|
||||
class="text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6"
|
||||
fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M15 19l-7-7 7-7" />
|
||||
</svg>
|
||||
</button>
|
||||
<div>
|
||||
<h2
|
||||
class="text-base font-semibold text-neutral-900 dark:text-white">
|
||||
Select Server
|
||||
</h2>
|
||||
@if ($this->selectedResourceName)
|
||||
<div class="text-xs text-neutral-500 dark:text-neutral-400">
|
||||
for {{ $this->selectedResourceName }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@if ($loadingServers)
|
||||
<div
|
||||
class="flex items-center gap-3 p-3 bg-neutral-50 dark:bg-coolgray-200 rounded-lg">
|
||||
<svg class="animate-spin h-5 w-5 text-yellow-500"
|
||||
xmlns="http://www.w3.org/2000/svg" fill="none"
|
||||
viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10"
|
||||
stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor"
|
||||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">
|
||||
</path>
|
||||
</svg>
|
||||
<span class="text-sm text-neutral-600 dark:text-neutral-400">Loading
|
||||
servers...</span>
|
||||
</div>
|
||||
@elseif (count($availableServers) > 0)
|
||||
@foreach ($availableServers as $index => $server)
|
||||
<button type="button"
|
||||
wire:click="selectServer({{ $server['id'] }}, true)"
|
||||
class="search-result-item w-full text-left block px-4 py-3 hover:bg-yellow-50 dark:hover:bg-yellow-900/20 transition-colors focus:outline-none focus:bg-yellow-100 dark:focus:bg-yellow-900/30">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex-1 min-w-0">
|
||||
<div
|
||||
class="font-medium text-neutral-900 dark:text-white">
|
||||
{{ $server['name'] }}
|
||||
</div>
|
||||
@if (!empty($server['description']))
|
||||
<div
|
||||
class="text-xs text-neutral-500 dark:text-neutral-400">
|
||||
{{ $server['description'] }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
class="shrink-0 h-5 w-5 text-yellow-500 dark:text-yellow-400"
|
||||
fill="none" viewBox="0 0 24 24"
|
||||
stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
@endforeach
|
||||
@else
|
||||
<div
|
||||
class="p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800">
|
||||
<p class="text-sm text-red-800 dark:text-red-200">No servers
|
||||
available</p>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Destination Selection -->
|
||||
@if ($selectedServerId !== null && $selectedDestinationUuid === null)
|
||||
<div class="mb-4" x-init="selectedIndex = -1">
|
||||
<div class="flex items-center gap-3 mb-3">
|
||||
<button type="button"
|
||||
@click="$wire.set('searchQuery', ''); setTimeout(() => $refs.searchInput.focus(), 100)"
|
||||
class="text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6"
|
||||
fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M15 19l-7-7 7-7" />
|
||||
</svg>
|
||||
</button>
|
||||
<div>
|
||||
<h2
|
||||
class="text-base font-semibold text-neutral-900 dark:text-white">
|
||||
Select Destination
|
||||
</h2>
|
||||
@if ($this->selectedResourceName)
|
||||
<div class="text-xs text-neutral-500 dark:text-neutral-400">
|
||||
for {{ $this->selectedResourceName }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@if ($loadingDestinations)
|
||||
<div
|
||||
class="flex items-center gap-3 p-3 bg-neutral-50 dark:bg-coolgray-200 rounded-lg">
|
||||
<svg class="animate-spin h-5 w-5 text-yellow-500"
|
||||
xmlns="http://www.w3.org/2000/svg" fill="none"
|
||||
viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12"
|
||||
r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor"
|
||||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">
|
||||
</path>
|
||||
</svg>
|
||||
<span
|
||||
class="text-sm text-neutral-600 dark:text-neutral-400">Loading
|
||||
destinations...</span>
|
||||
</div>
|
||||
@elseif (count($availableDestinations) > 0)
|
||||
@foreach ($availableDestinations as $index => $destination)
|
||||
<button type="button"
|
||||
wire:click="selectDestination('{{ $destination['uuid'] }}', true)"
|
||||
class="search-result-item w-full text-left block px-4 py-3 hover:bg-yellow-50 dark:hover:bg-yellow-900/20 transition-colors focus:outline-none focus:bg-yellow-100 dark:focus:bg-yellow-900/30">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex-1 min-w-0">
|
||||
<div
|
||||
class="font-medium text-neutral-900 dark:text-white">
|
||||
{{ $destination['name'] }}
|
||||
</div>
|
||||
<div
|
||||
class="text-xs text-neutral-500 dark:text-neutral-400">
|
||||
Network: {{ $destination['network'] }}
|
||||
</div>
|
||||
</div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
class="shrink-0 h-5 w-5 text-yellow-500 dark:text-yellow-400"
|
||||
fill="none" viewBox="0 0 24 24"
|
||||
stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
@endforeach
|
||||
@else
|
||||
<div
|
||||
class="p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800">
|
||||
<p class="text-sm text-red-800 dark:text-red-200">No destinations
|
||||
available</p>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Project Selection -->
|
||||
@if ($selectedDestinationUuid !== null && $selectedProjectUuid === null)
|
||||
<div class="mb-4" x-init="selectedIndex = -1">
|
||||
<div class="flex items-center gap-3 mb-3">
|
||||
<button type="button"
|
||||
@click="$wire.set('searchQuery', ''); setTimeout(() => $refs.searchInput.focus(), 100)"
|
||||
class="text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6"
|
||||
fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M15 19l-7-7 7-7" />
|
||||
</svg>
|
||||
</button>
|
||||
<div>
|
||||
<h2
|
||||
class="text-base font-semibold text-neutral-900 dark:text-white">
|
||||
Select Project
|
||||
</h2>
|
||||
@if ($this->selectedResourceName)
|
||||
<div class="text-xs text-neutral-500 dark:text-neutral-400">
|
||||
for {{ $this->selectedResourceName }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@if ($loadingProjects)
|
||||
<div
|
||||
class="flex items-center gap-3 p-3 bg-neutral-50 dark:bg-coolgray-200 rounded-lg">
|
||||
<svg class="animate-spin h-5 w-5 text-yellow-500"
|
||||
xmlns="http://www.w3.org/2000/svg" fill="none"
|
||||
viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12"
|
||||
r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor"
|
||||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">
|
||||
</path>
|
||||
</svg>
|
||||
<span
|
||||
class="text-sm text-neutral-600 dark:text-neutral-400">Loading
|
||||
projects...</span>
|
||||
</div>
|
||||
@elseif (count($availableProjects) > 0)
|
||||
@foreach ($availableProjects as $index => $project)
|
||||
<button type="button"
|
||||
wire:click="selectProject('{{ $project['uuid'] }}', true)"
|
||||
class="search-result-item w-full text-left block px-4 py-3 hover:bg-yellow-50 dark:hover:bg-yellow-900/20 transition-colors focus:outline-none focus:bg-yellow-100 dark:focus:bg-yellow-900/30">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex-1 min-w-0">
|
||||
<div
|
||||
class="font-medium text-neutral-900 dark:text-white">
|
||||
{{ $project['name'] }}
|
||||
</div>
|
||||
@if (!empty($project['description']))
|
||||
<div
|
||||
class="text-xs text-neutral-500 dark:text-neutral-400">
|
||||
{{ $project['description'] }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
class="shrink-0 h-5 w-5 text-yellow-500 dark:text-yellow-400"
|
||||
fill="none" viewBox="0 0 24 24"
|
||||
stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
@endforeach
|
||||
@else
|
||||
<div
|
||||
class="p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800">
|
||||
<p class="text-sm text-red-800 dark:text-red-200">No projects
|
||||
available</p>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Environment Selection -->
|
||||
@if ($selectedProjectUuid !== null && $selectedEnvironmentUuid === null)
|
||||
<div class="mb-4" x-init="selectedIndex = -1">
|
||||
<div class="flex items-center gap-3 mb-3">
|
||||
<button type="button"
|
||||
@click="$wire.set('searchQuery', ''); setTimeout(() => $refs.searchInput.focus(), 100)"
|
||||
class="text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6"
|
||||
fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M15 19l-7-7 7-7" />
|
||||
</svg>
|
||||
</button>
|
||||
<div>
|
||||
<h2
|
||||
class="text-base font-semibold text-neutral-900 dark:text-white">
|
||||
Select Environment
|
||||
</h2>
|
||||
@if ($this->selectedResourceName)
|
||||
<div class="text-xs text-neutral-500 dark:text-neutral-400">
|
||||
for {{ $this->selectedResourceName }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@if ($loadingEnvironments)
|
||||
<div
|
||||
class="flex items-center gap-3 p-3 bg-neutral-50 dark:bg-coolgray-200 rounded-lg">
|
||||
<svg class="animate-spin h-5 w-5 text-yellow-500"
|
||||
xmlns="http://www.w3.org/2000/svg" fill="none"
|
||||
viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12"
|
||||
r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor"
|
||||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">
|
||||
</path>
|
||||
</svg>
|
||||
<span
|
||||
class="text-sm text-neutral-600 dark:text-neutral-400">Loading
|
||||
environments...</span>
|
||||
</div>
|
||||
@elseif (count($availableEnvironments) > 0)
|
||||
@foreach ($availableEnvironments as $index => $environment)
|
||||
<button type="button"
|
||||
wire:click="selectEnvironment('{{ $environment['uuid'] }}', true)"
|
||||
class="search-result-item w-full text-left block px-4 py-3 hover:bg-yellow-50 dark:hover:bg-yellow-900/20 transition-colors focus:outline-none focus:bg-yellow-100 dark:focus:bg-yellow-900/30">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex-1 min-w-0">
|
||||
<div
|
||||
class="font-medium text-neutral-900 dark:text-white">
|
||||
{{ $environment['name'] }}
|
||||
</div>
|
||||
@if (!empty($environment['description']))
|
||||
<div
|
||||
class="text-xs text-neutral-500 dark:text-neutral-400">
|
||||
{{ $environment['description'] }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
class="shrink-0 h-5 w-5 text-yellow-500 dark:text-yellow-400"
|
||||
fill="none" viewBox="0 0 24 24"
|
||||
stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
@endforeach
|
||||
@else
|
||||
<div
|
||||
class="p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800">
|
||||
<p class="text-sm text-red-800 dark:text-red-200">No environments
|
||||
available</p>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@elseif ($isCreateMode && count($this->filteredCreatableItems) > 0 && !$autoOpenResource)
|
||||
<!-- Create new resources section -->
|
||||
<div class="py-2" x-data="{
|
||||
openModal(type) {
|
||||
// Close the parent search modal properly
|
||||
const parentModal = this.$root.closest('[x-data]');
|
||||
if (parentModal && parentModal.__x) {
|
||||
parentModal.__x.$data.closeModal();
|
||||
}
|
||||
// Dispatch event to open creation modal after a short delay
|
||||
setTimeout(() => {
|
||||
this.$dispatch('open-create-modal-' + type);
|
||||
}, 150);
|
||||
}
|
||||
}">
|
||||
<div
|
||||
<div class="py-2">
|
||||
{{-- <div
|
||||
class="px-4 py-2 bg-yellow-50 dark:bg-yellow-900/20 border-b border-yellow-100 dark:border-yellow-800">
|
||||
<h3 class="text-sm font-semibold text-yellow-900 dark:text-yellow-100">
|
||||
Create New Resources
|
||||
|
|
@ -177,96 +524,166 @@ class="px-4 py-2 bg-yellow-50 dark:bg-yellow-900/20 border-b border-yellow-100 d
|
|||
<p class="text-xs text-yellow-700 dark:text-yellow-300 mt-0.5">
|
||||
Click on any item below to create a new resource
|
||||
</p>
|
||||
</div>
|
||||
@foreach ($creatableItems as $item)
|
||||
<button type="button" @click="openModal('{{ $item['type'] }}')"
|
||||
class="search-result-item w-full text-left block px-4 py-3 hover:bg-yellow-50 dark:hover:bg-yellow-900/20 transition-colors focus:outline-none focus:bg-yellow-100 dark:focus:bg-yellow-900/30 border-transparent hover:border-yellow-500 focus:border-yellow-500">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-3 flex-1 min-w-0">
|
||||
<div
|
||||
class="flex-shrink-0 w-10 h-10 rounded-lg bg-yellow-100 dark:bg-yellow-900/40 flex items-center justify-center">
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-5 w-5 text-yellow-600 dark:text-yellow-400"
|
||||
fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M12 4v16m8-8H4" />
|
||||
</svg>
|
||||
</div> --}}
|
||||
|
||||
@php
|
||||
$grouped = collect($this->filteredCreatableItems)->groupBy('category');
|
||||
@endphp
|
||||
|
||||
@foreach ($grouped as $category => $items)
|
||||
<!-- Category Header -->
|
||||
<div class="px-4 pt-3 pb-1">
|
||||
<h4
|
||||
class="text-xs font-semibold text-neutral-500 dark:text-neutral-400 uppercase tracking-wider">
|
||||
{{ $category }}
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
<!-- Category Items -->
|
||||
@foreach ($items as $item)
|
||||
<button type="button"
|
||||
wire:click="navigateToResource('{{ $item['type'] }}')"
|
||||
class="search-result-item w-full text-left block px-4 py-3 hover:bg-yellow-50 dark:hover:bg-yellow-900/20 transition-colors focus:outline-none focus:bg-yellow-100 dark:focus:bg-yellow-900/30 border-transparent hover:border-yellow-500 focus:border-yellow-500">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-3 flex-1 min-w-0">
|
||||
<div
|
||||
class="flex-shrink-0 w-10 h-10 rounded-lg bg-yellow-100 dark:bg-yellow-900/40 flex items-center justify-center">
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-5 w-5 text-yellow-600 dark:text-yellow-400"
|
||||
fill="none" viewBox="0 0 24 24"
|
||||
stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M12 4v16m8-8H4" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
<div
|
||||
class="font-medium text-neutral-900 dark:text-white truncate">
|
||||
{{ $item['name'] }}
|
||||
</div>
|
||||
@if (isset($item['quickcommand']))
|
||||
<span
|
||||
class="text-xs text-neutral-500 dark:text-neutral-400 shrink-0">{{ $item['quickcommand'] }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div
|
||||
class="text-sm text-neutral-600 dark:text-neutral-400 truncate">
|
||||
{{ $item['description'] }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
class="shrink-0 h-5 w-5 text-yellow-500 dark:text-yellow-400 self-center"
|
||||
fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</div>
|
||||
@elseif (strlen($searchQuery) >= 1 && count($searchResults) > 0)
|
||||
<div class="py-2">
|
||||
@foreach ($searchResults as $index => $result)
|
||||
@if (isset($result['is_creatable_suggestion']) && $result['is_creatable_suggestion'])
|
||||
{{-- Creatable suggestion with yellow theme --}}
|
||||
<button type="button"
|
||||
wire:click="navigateToResource('{{ $result['type'] }}')"
|
||||
class="search-result-item w-full text-left block px-4 py-3 bg-yellow-50 dark:bg-yellow-900/10 hover:bg-yellow-100 dark:hover:bg-yellow-900/20 transition-colors focus:outline-none focus:bg-yellow-100 dark:focus:bg-yellow-900/30 border-l-4 border-yellow-500">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-3 flex-1 min-w-0">
|
||||
<div
|
||||
class="flex-shrink-0 w-10 h-10 rounded-lg bg-yellow-100 dark:bg-yellow-900/40 flex items-center justify-center">
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-5 w-5 text-yellow-600 dark:text-yellow-400"
|
||||
fill="none" viewBox="0 0 24 24"
|
||||
stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M12 4v16m8-8H4" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
<span
|
||||
class="font-medium text-neutral-900 dark:text-white truncate">
|
||||
{{ $result['name'] }}
|
||||
</span>
|
||||
<span
|
||||
class="px-2 py-0.5 text-xs rounded-full bg-yellow-100 dark:bg-yellow-900/40 text-yellow-700 dark:text-yellow-300 shrink-0">
|
||||
Create New
|
||||
</span>
|
||||
@if (isset($result['quickcommand']))
|
||||
<span
|
||||
class="text-xs text-neutral-500 dark:text-neutral-400 shrink-0">{{ $result['quickcommand'] }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div
|
||||
class="text-sm text-neutral-600 dark:text-neutral-400 truncate">
|
||||
{{ $result['description'] }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
class="shrink-0 h-5 w-5 text-yellow-500 dark:text-yellow-400 self-center"
|
||||
fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
@else
|
||||
{{-- Regular search result --}}
|
||||
<a href="{{ $result['link'] ?? '#' }}"
|
||||
class="search-result-item block px-4 py-3 hover:bg-neutral-50 dark:hover:bg-coolgray-200 transition-colors focus:outline-none focus:bg-yellow-50 dark:focus:bg-yellow-900/20 border-transparent hover:border-coollabs focus:border-yellow-500 dark:focus:border-yellow-400">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
<span
|
||||
class="font-medium text-neutral-900 dark:text-white truncate">
|
||||
{{ $item['name'] }}
|
||||
{{ $result['name'] }}
|
||||
</span>
|
||||
<span
|
||||
class="px-2 py-0.5 text-xs rounded-full bg-yellow-100 dark:bg-yellow-900/40 text-yellow-700 dark:text-yellow-300 shrink-0">
|
||||
New
|
||||
class="px-2 py-0.5 text-xs rounded-full bg-neutral-100 dark:bg-coolgray-300 text-neutral-700 dark:text-neutral-300 shrink-0">
|
||||
@if ($result['type'] === 'application')
|
||||
Application
|
||||
@elseif ($result['type'] === 'service')
|
||||
Service
|
||||
@elseif ($result['type'] === 'database')
|
||||
{{ ucfirst($result['subtype'] ?? 'Database') }}
|
||||
@elseif ($result['type'] === 'server')
|
||||
Server
|
||||
@elseif ($result['type'] === 'project')
|
||||
Project
|
||||
@elseif ($result['type'] === 'environment')
|
||||
Environment
|
||||
@endif
|
||||
</span>
|
||||
</div>
|
||||
<div class="text-sm text-neutral-600 dark:text-neutral-400">
|
||||
{{ $item['description'] }}
|
||||
</div>
|
||||
@if (!empty($result['project']) && !empty($result['environment']))
|
||||
<div
|
||||
class="text-xs text-neutral-500 dark:text-neutral-400 mb-1">
|
||||
{{ $result['project'] }} /
|
||||
{{ $result['environment'] }}
|
||||
</div>
|
||||
@endif
|
||||
@if (!empty($result['description']))
|
||||
<div
|
||||
class="text-sm text-neutral-600 dark:text-neutral-400">
|
||||
{{ Str::limit($result['description'], 80) }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
class="shrink-0 h-5 w-5 text-neutral-300 dark:text-neutral-600 self-center"
|
||||
fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
class="shrink-0 h-5 w-5 text-yellow-500 dark:text-yellow-400 self-center"
|
||||
fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
@endforeach
|
||||
</div>
|
||||
@elseif (strlen($searchQuery) >= 2 && count($searchResults) > 0)
|
||||
<div class="py-2">
|
||||
@foreach ($searchResults as $index => $result)
|
||||
<a href="{{ $result['link'] ?? '#' }}"
|
||||
class="search-result-item block px-4 py-3 hover:bg-neutral-50 dark:hover:bg-coolgray-200 transition-colors focus:outline-none focus:bg-yellow-50 dark:focus:bg-yellow-900/20 border-transparent hover:border-coollabs focus:border-yellow-500 dark:focus:border-yellow-400">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
<span
|
||||
class="font-medium text-neutral-900 dark:text-white truncate">
|
||||
{{ $result['name'] }}
|
||||
</span>
|
||||
<span
|
||||
class="px-2 py-0.5 text-xs rounded-full bg-neutral-100 dark:bg-coolgray-300 text-neutral-700 dark:text-neutral-300 shrink-0">
|
||||
@if ($result['type'] === 'application')
|
||||
Application
|
||||
@elseif ($result['type'] === 'service')
|
||||
Service
|
||||
@elseif ($result['type'] === 'database')
|
||||
{{ ucfirst($result['subtype'] ?? 'Database') }}
|
||||
@elseif ($result['type'] === 'server')
|
||||
Server
|
||||
@elseif ($result['type'] === 'project')
|
||||
Project
|
||||
@elseif ($result['type'] === 'environment')
|
||||
Environment
|
||||
@endif
|
||||
</span>
|
||||
</div>
|
||||
@if (!empty($result['project']) && !empty($result['environment']))
|
||||
<div
|
||||
class="text-xs text-neutral-500 dark:text-neutral-400 mb-1">
|
||||
{{ $result['project'] }} / {{ $result['environment'] }}
|
||||
</div>
|
||||
@endif
|
||||
@if (!empty($result['description']))
|
||||
<div class="text-sm text-neutral-600 dark:text-neutral-400">
|
||||
{{ Str::limit($result['description'], 80) }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
class="shrink-0 h-5 w-5 text-neutral-300 dark:text-neutral-600 self-center"
|
||||
fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</div>
|
||||
</a>
|
||||
</a>
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
@elseif (strlen($searchQuery) >= 2 && count($searchResults) === 0 && !$autoOpenResource)
|
||||
|
|
@ -280,14 +697,6 @@ class="shrink-0 h-5 w-5 text-neutral-300 dark:text-neutral-600 self-center"
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@elseif (strlen($searchQuery) > 0 && strlen($searchQuery) < 2)
|
||||
<div class="flex items-center justify-center py-12 px-4">
|
||||
<div class="text-center">
|
||||
<p class="text-sm text-neutral-600 dark:text-neutral-400">
|
||||
Type at least 2 characters to search
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue