diff --git a/apps/dokploy/components/dashboard/search-command.tsx b/apps/dokploy/components/dashboard/search-command.tsx index 511ca00ab..42430b6d0 100644 --- a/apps/dokploy/components/dashboard/search-command.tsx +++ b/apps/dokploy/components/dashboard/search-command.tsx @@ -3,6 +3,10 @@ import { BookIcon, CircuitBoard, GlobeIcon } from "lucide-react"; import { useRouter } from "next/router"; import React from "react"; +import { + extractServices, + type Services, +} from "@/components/dashboard/settings/users/add-permissions"; import { MariadbIcon, MongodbIcon, @@ -20,13 +24,34 @@ import { CommandSeparator, } from "@/components/ui/command"; import { authClient } from "@/lib/auth-client"; -// import { -// extractServices, -// type Services, -// } from "@/pages/dashboard/project/[projectId]"; import { api } from "@/utils/api"; import { StatusTooltip } from "../shared/status-tooltip"; +// Extended Services type to include environmentId and environmentName for search navigation +type SearchServices = Services & { + environmentId: string; + environmentName: string; +}; + +const extractAllServicesFromProject = (project: any): SearchServices[] => { + const allServices: SearchServices[] = []; + + // Iterate through all environments in the project + project.environments?.forEach((environment: any) => { + const environmentServices = extractServices(environment); + const servicesWithEnvironmentId: SearchServices[] = environmentServices.map( + (service) => ({ + ...service, + environmentId: environment.environmentId, + environmentName: environment.name, + }), + ); + allServices.push(...servicesWithEnvironmentId); + }); + + return allServices; +}; + export const SearchCommand = () => { const router = useRouter(); const [open, setOpen] = React.useState(false); @@ -51,7 +76,7 @@ export const SearchCommand = () => { return (