Skip to content

Commit e05f31d

Browse files
authored
Merge pull request #3857 from Dokploy/feat/improve-queries
feat: enhance project and environment services with additional column…
2 parents e275e91 + cc3b902 commit e05f31d

File tree

7 files changed

+306
-162
lines changed

7 files changed

+306
-162
lines changed

apps/dokploy/components/dashboard/project/duplicate-project.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
import { api } from "@/utils/api";
2626

2727
export type Services = {
28-
appName: string;
2928
serverId?: string | null;
3029
name: string;
3130
type:

apps/dokploy/components/dashboard/projects/show.tsx

Lines changed: 0 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
AlertTriangle,
33
ArrowUpDown,
44
BookIcon,
5-
ExternalLinkIcon,
65
FolderInput,
76
Loader2,
87
MoreHorizontalIcon,
@@ -16,7 +15,6 @@ import { toast } from "sonner";
1615
import { BreadcrumbSidebar } from "@/components/shared/breadcrumb-sidebar";
1716
import { DateTooltip } from "@/components/shared/date-tooltip";
1817
import { FocusShortcutInput } from "@/components/shared/focus-shortcut-input";
19-
import { StatusTooltip } from "@/components/shared/status-tooltip";
2018
import {
2119
AlertDialog,
2220
AlertDialogAction,
@@ -40,10 +38,8 @@ import {
4038
import {
4139
DropdownMenu,
4240
DropdownMenuContent,
43-
DropdownMenuGroup,
4441
DropdownMenuItem,
4542
DropdownMenuLabel,
46-
DropdownMenuSeparator,
4743
DropdownMenuTrigger,
4844
} from "@/components/ui/dropdown-menu";
4945
import {
@@ -280,14 +276,6 @@ export const ShowProjects = () => {
280276
)
281277
.reduce((acc, curr) => acc + curr, 0);
282278

283-
const haveServicesWithDomains = project?.environments
284-
.map(
285-
(env) =>
286-
env.applications.length > 0 ||
287-
env.compose.length > 0,
288-
)
289-
.some(Boolean);
290-
291279
// Find default environment from accessible environments, or fall back to first accessible environment
292280
const accessibleEnvironment =
293281
project?.environments.find((env) => env.isDefault) ||
@@ -313,122 +301,6 @@ export const ShowProjects = () => {
313301
}}
314302
>
315303
<Card className="group relative w-full h-full bg-transparent transition-colors hover:bg-border">
316-
{haveServicesWithDomains ? (
317-
<DropdownMenu>
318-
<DropdownMenuTrigger asChild>
319-
<Button
320-
className="absolute -right-3 -top-3 size-9 translate-y-1 rounded-full p-0 opacity-0 transition-all duration-200 group-hover:translate-y-0 group-hover:opacity-100"
321-
size="sm"
322-
variant="default"
323-
>
324-
<ExternalLinkIcon className="size-3.5" />
325-
</Button>
326-
</DropdownMenuTrigger>
327-
<DropdownMenuContent
328-
className="w-[200px] space-y-2 overflow-y-auto max-h-[400px]"
329-
onClick={(e) => e.stopPropagation()}
330-
>
331-
{project.environments.some(
332-
(env) => env.applications.length > 0,
333-
) && (
334-
<DropdownMenuGroup>
335-
<DropdownMenuLabel>
336-
Applications
337-
</DropdownMenuLabel>
338-
{project.environments.map((env) =>
339-
env.applications.map((app) => (
340-
<div key={app.applicationId}>
341-
<DropdownMenuSeparator />
342-
<DropdownMenuGroup>
343-
<DropdownMenuLabel className="font-normal capitalize text-xs flex items-center justify-between">
344-
{app.name}
345-
<StatusTooltip
346-
status={
347-
app.applicationStatus
348-
}
349-
/>
350-
</DropdownMenuLabel>
351-
<DropdownMenuSeparator />
352-
{app.domains.map((domain) => (
353-
<DropdownMenuItem
354-
key={domain.domainId}
355-
asChild
356-
>
357-
<Link
358-
className="space-x-4 text-xs cursor-pointer justify-between"
359-
target="_blank"
360-
href={`${
361-
domain.https
362-
? "https"
363-
: "http"
364-
}://${domain.host}${
365-
domain.path
366-
}`}
367-
>
368-
<span className="truncate">
369-
{domain.host}
370-
</span>
371-
<ExternalLinkIcon className="size-4 shrink-0" />
372-
</Link>
373-
</DropdownMenuItem>
374-
))}
375-
</DropdownMenuGroup>
376-
</div>
377-
)),
378-
)}
379-
</DropdownMenuGroup>
380-
)}
381-
{project.environments.some(
382-
(env) => env.compose.length > 0,
383-
) && (
384-
<DropdownMenuGroup>
385-
<DropdownMenuLabel>
386-
Compose
387-
</DropdownMenuLabel>
388-
{project.environments.map((env) =>
389-
env.compose.map((comp) => (
390-
<div key={comp.composeId}>
391-
<DropdownMenuSeparator />
392-
<DropdownMenuGroup>
393-
<DropdownMenuLabel className="font-normal capitalize text-xs flex items-center justify-between">
394-
{comp.name}
395-
<StatusTooltip
396-
status={comp.composeStatus}
397-
/>
398-
</DropdownMenuLabel>
399-
<DropdownMenuSeparator />
400-
{comp.domains.map((domain) => (
401-
<DropdownMenuItem
402-
key={domain.domainId}
403-
asChild
404-
>
405-
<Link
406-
className="space-x-4 text-xs cursor-pointer justify-between"
407-
target="_blank"
408-
href={`${
409-
domain.https
410-
? "https"
411-
: "http"
412-
}://${domain.host}${
413-
domain.path
414-
}`}
415-
>
416-
<span className="truncate">
417-
{domain.host}
418-
</span>
419-
<ExternalLinkIcon className="size-4 shrink-0" />
420-
</Link>
421-
</DropdownMenuItem>
422-
))}
423-
</DropdownMenuGroup>
424-
</div>
425-
)),
426-
)}
427-
</DropdownMenuGroup>
428-
)}
429-
</DropdownMenuContent>
430-
</DropdownMenu>
431-
) : null}
432304
<CardHeader>
433305
<CardTitle className="flex items-center justify-between gap-2 overflow-clip">
434306
<span className="flex flex-col gap-1.5 ">

apps/dokploy/components/dashboard/settings/servers/setup-monitoring.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const SetupMonitoring = ({ serverId }: Props) => {
100100

101101
const url = useUrl();
102102

103-
const { data: projects } = api.project.all.useQuery();
103+
const { data: projects } = api.project.allForPermissions.useQuery();
104104

105105
const extractServicesFromProjects = () => {
106106
if (!projects) return [];

apps/dokploy/components/dashboard/settings/users/add-permissions.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ import {
2828
import { Switch } from "@/components/ui/switch";
2929
import { api, type RouterOutputs } from "@/utils/api";
3030

31-
type Project = RouterOutputs["project"]["all"][number];
32-
type Environment = Project["environments"][number];
31+
/** Shape returned by project.allForPermissions (admin only). Used for the permissions UI. */
32+
type ProjectForPermissions =
33+
RouterOutputs["project"]["allForPermissions"][number];
34+
type EnvironmentForPermissions = ProjectForPermissions["environments"][number];
35+
36+
type Environment = EnvironmentForPermissions;
3337

3438
export type Services = {
3539
appName: string;
@@ -173,7 +177,9 @@ interface Props {
173177

174178
export const AddUserPermissions = ({ userId }: Props) => {
175179
const [isOpen, setIsOpen] = useState(false);
176-
const { data: projects } = api.project.all.useQuery();
180+
const { data: projects } = api.project.allForPermissions.useQuery(undefined, {
181+
enabled: isOpen,
182+
});
177183

178184
const { data, refetch } = api.user.one.useQuery(
179185
{

apps/dokploy/pages/dashboard/project/[projectId]/environment/[environmentId].tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ import { appRouter } from "@/server/api/root";
100100
import { api } from "@/utils/api";
101101

102102
export type Services = {
103-
appName: string;
104103
serverId?: string | null;
105104
serverName?: string | null;
106105
name: string;
@@ -146,7 +145,6 @@ export const extractServicesFromEnvironment = (
146145
}
147146
}
148147
return {
149-
appName: item.appName,
150148
name: item.name,
151149
type: "application",
152150
id: item.applicationId,
@@ -161,7 +159,6 @@ export const extractServicesFromEnvironment = (
161159

162160
const mariadb: Services[] =
163161
environment.mariadb?.map((item) => ({
164-
appName: item.appName,
165162
name: item.name,
166163
type: "mariadb",
167164
id: item.mariadbId,
@@ -174,7 +171,6 @@ export const extractServicesFromEnvironment = (
174171

175172
const postgres: Services[] =
176173
environment.postgres?.map((item) => ({
177-
appName: item.appName,
178174
name: item.name,
179175
type: "postgres",
180176
id: item.postgresId,
@@ -187,7 +183,6 @@ export const extractServicesFromEnvironment = (
187183

188184
const mongo: Services[] =
189185
environment.mongo?.map((item) => ({
190-
appName: item.appName,
191186
name: item.name,
192187
type: "mongo",
193188
id: item.mongoId,
@@ -200,7 +195,6 @@ export const extractServicesFromEnvironment = (
200195

201196
const redis: Services[] =
202197
environment.redis?.map((item) => ({
203-
appName: item.appName,
204198
name: item.name,
205199
type: "redis",
206200
id: item.redisId,
@@ -213,7 +207,6 @@ export const extractServicesFromEnvironment = (
213207

214208
const mysql: Services[] =
215209
environment.mysql?.map((item) => ({
216-
appName: item.appName,
217210
name: item.name,
218211
type: "mysql",
219212
id: item.mysqlId,
@@ -242,7 +235,6 @@ export const extractServicesFromEnvironment = (
242235
}
243236
}
244237
return {
245-
appName: item.appName,
246238
name: item.name,
247239
type: "compose",
248240
id: item.composeId,

0 commit comments

Comments
 (0)