Skip to content

Commit 6c1f237

Browse files
committed
refactor: clean up project dashboard and API response structure
Removed unused imports and redundant code in the project dashboard component to enhance readability. Updated the API project router to streamline the data structure by eliminating unnecessary domain retrievals, while ensuring essential application and compose details are still included. This refactor improves maintainability and optimizes data handling for the project management interface.
1 parent 7da6986 commit 6c1f237

3 files changed

Lines changed: 4 additions & 135 deletions

File tree

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/users/add-permissions.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ type ProjectForPermissions =
3333
RouterOutputs["project"]["allForPermissions"][number];
3434
type EnvironmentForPermissions = ProjectForPermissions["environments"][number];
3535

36-
type Project = ProjectForPermissions;
3736
type Environment = EnvironmentForPermissions;
3837

3938
export type Services = {

apps/dokploy/server/api/routers/project.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,10 @@ export const projectRouter = createTRPCRouter({
284284
environments: {
285285
with: {
286286
applications: {
287-
with: {
288-
domains: true,
289-
},
290287
columns: {
291288
applicationId: true,
289+
name: true,
290+
applicationStatus: true,
292291
},
293292
},
294293
mariadb: {
@@ -317,11 +316,10 @@ export const projectRouter = createTRPCRouter({
317316
},
318317
},
319318
compose: {
320-
with: {
321-
domains: true,
322-
},
323319
columns: {
324320
composeId: true,
321+
name: true,
322+
composeStatus: true,
325323
},
326324
},
327325
},

0 commit comments

Comments
 (0)