Skip to content

Commit 518ee44

Browse files
committed
feat: move deployments into an overview page tab
1 parent 046a608 commit 518ee44

7 files changed

Lines changed: 114 additions & 122 deletions

File tree

‎apps/dokploy/components/dashboard/home/show-home.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ export const ShowHome = () => {
223223
</div>
224224
{canReadDeployments && (
225225
<Link
226-
href="/dashboard/deployments"
226+
href="/dashboard/overview?tab=deployments"
227227
className="text-xs text-muted-foreground hover:text-foreground transition-colors"
228228
>
229229
view all →
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { Rocket } from "lucide-react";
2+
import { useRouter } from "next/router";
3+
import { ShowDeploymentsTable } from "@/components/dashboard/deployments/show-deployments-table";
4+
import { ShowQueueTable } from "@/components/dashboard/deployments/show-queue-table";
5+
import {
6+
Card,
7+
CardDescription,
8+
CardHeader,
9+
CardTitle,
10+
} from "@/components/ui/card";
11+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
12+
13+
const SUBTAB_VALUES = ["deployments", "queue"] as const;
14+
type SubtabValue = (typeof SUBTAB_VALUES)[number];
15+
const DEFAULT_SUBTAB: SubtabValue = "deployments";
16+
17+
function isValidSubtab(t: string): t is SubtabValue {
18+
return SUBTAB_VALUES.includes(t as SubtabValue);
19+
}
20+
21+
export const ShowOverviewDeployments = () => {
22+
const router = useRouter();
23+
const subtab =
24+
typeof router.query.subtab === "string" &&
25+
isValidSubtab(router.query.subtab)
26+
? router.query.subtab
27+
: DEFAULT_SUBTAB;
28+
29+
const setSubtab = (value: string) => {
30+
if (!isValidSubtab(value)) return;
31+
const { subtab: _current, ...query } = router.query;
32+
router.replace(
33+
{
34+
pathname: router.pathname,
35+
query: value === DEFAULT_SUBTAB ? query : { ...query, subtab: value },
36+
},
37+
undefined,
38+
{ shallow: true },
39+
);
40+
};
41+
42+
return (
43+
<Card className="h-full bg-sidebar p-2.5 rounded-xl min-h-[45vh]">
44+
<div className="rounded-xl bg-background shadow-md h-full">
45+
<CardHeader>
46+
<div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
47+
<div>
48+
<CardTitle className="text-xl font-bold flex items-center gap-2">
49+
<Rocket className="size-5" />
50+
Deployments
51+
</CardTitle>
52+
<CardDescription>
53+
All application and compose deployments in one place.
54+
</CardDescription>
55+
</div>
56+
</div>
57+
<Tabs
58+
value={subtab}
59+
onValueChange={setSubtab}
60+
className="w-full min-w-0"
61+
>
62+
<TabsList className="mt-2">
63+
<TabsTrigger value="deployments">Deployments</TabsTrigger>
64+
<TabsTrigger value="queue">Queue</TabsTrigger>
65+
</TabsList>
66+
<TabsContent value="deployments" className="mt-0 min-w-0 pt-4">
67+
<ShowDeploymentsTable />
68+
</TabsContent>
69+
<TabsContent value="queue" className="mt-0 pt-4">
70+
<ShowQueueTable />
71+
</TabsContent>
72+
</Tabs>
73+
</CardHeader>
74+
</div>
75+
</Card>
76+
);
77+
};

‎apps/dokploy/components/dashboard/overview/show-overview-domains.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ExternalLink, Loader2 } from "lucide-react";
44
import Link from "next/link";
55
import { useMemo, useState } from "react";
66
import { toast } from "sonner";
7+
import { COMPOSE_REDEPLOY_TOAST } from "@/components/dashboard/application/domains/redeploy-hint";
78
import { DateTooltip } from "@/components/shared/date-tooltip";
89
import { Badge } from "@/components/ui/badge";
910
import { Button } from "@/components/ui/button";
@@ -71,7 +72,12 @@ export const ShowOverviewDomains = () => {
7172
try {
7273
const result = await toggleEnable({ domainId: domain.domainId });
7374
utils.overview.domains.invalidate();
74-
toast.success(result.enabled ? "Domain enabled" : "Domain disabled");
75+
toast.success(
76+
result.enabled ? "Domain enabled" : "Domain disabled",
77+
result.requiresRedeploy
78+
? { description: COMPOSE_REDEPLOY_TOAST }
79+
: undefined,
80+
);
7581
} catch {
7682
toast.error(`Error updating "${domain.host}"`);
7783
}

‎apps/dokploy/components/dashboard/search-command.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export const SearchCommand = () => {
175175
</CommandItem>
176176
<CommandItem
177177
onSelect={() => {
178-
router.push("/dashboard/deployments");
178+
router.push("/dashboard/overview?tab=deployments");
179179
setOpen(false);
180180
}}
181181
>

‎apps/dokploy/components/layouts/side.tsx‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {
2929
type LucideIcon,
3030
Package,
3131
Palette,
32-
Rocket,
3332
Server,
3433
ShieldCheck,
3534
Smartphone,
@@ -179,10 +178,11 @@ const MENU: Menu = {
179178
},
180179
{
181180
isSingle: true,
182-
title: "Deployments",
183-
url: "/dashboard/deployments",
184-
icon: Rocket,
185-
isEnabled: ({ permissions }) => !!permissions?.deployment.read,
181+
title: "Overview",
182+
url: "/dashboard/overview",
183+
icon: LayoutGrid,
184+
// Only enabled for users with access to services
185+
isEnabled: ({ permissions }) => !!permissions?.service.read,
186186
},
187187
{
188188
isSingle: true,
@@ -216,14 +216,6 @@ const MENU: Menu = {
216216
// Only enabled for users with access to Docker
217217
isEnabled: ({ permissions }) => !!permissions?.docker.read,
218218
},
219-
{
220-
isSingle: true,
221-
title: "Overview",
222-
url: "/dashboard/overview",
223-
icon: LayoutGrid,
224-
// Only enabled for users with access to services
225-
isEnabled: ({ permissions }) => !!permissions?.service.read,
226-
},
227219
{
228220
isSingle: true,
229221
title: "Requests",
Lines changed: 10 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,19 @@
1-
import { validateRequest } from "@dokploy/server/lib/auth";
2-
import { hasPermission } from "@dokploy/server/services/permission";
3-
import { Rocket } from "lucide-react";
41
import type { GetServerSidePropsContext } from "next";
5-
import { useRouter } from "next/router";
6-
import type { ReactElement } from "react";
7-
import { ShowDeploymentsTable } from "@/components/dashboard/deployments/show-deployments-table";
8-
import { ShowQueueTable } from "@/components/dashboard/deployments/show-queue-table";
9-
import { DashboardLayout } from "@/components/layouts/dashboard-layout";
10-
import {
11-
Card,
12-
CardDescription,
13-
CardHeader,
14-
CardTitle,
15-
} from "@/components/ui/card";
16-
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
172

18-
const TAB_VALUES = ["deployments", "queue"] as const;
19-
type TabValue = (typeof TAB_VALUES)[number];
20-
21-
function isValidTab(t: string): t is TabValue {
22-
return TAB_VALUES.includes(t as TabValue);
23-
}
24-
25-
function DeploymentsPage() {
26-
const router = useRouter();
27-
const tab =
28-
router.query.tab && isValidTab(router.query.tab as string)
29-
? (router.query.tab as TabValue)
30-
: "deployments";
31-
32-
const setTab = (value: string) => {
33-
if (!isValidTab(value)) return;
34-
router.replace(
35-
{ pathname: "/dashboard/deployments", query: { tab: value } },
36-
undefined,
37-
{ shallow: true },
38-
);
39-
};
40-
41-
return (
42-
<div className="w-full">
43-
<Card className="h-full bg-sidebar p-2.5 rounded-xl min-h-[45vh]">
44-
<div className="rounded-xl bg-background shadow-md h-full">
45-
<CardHeader>
46-
<div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
47-
<div>
48-
<CardTitle className="text-xl font-bold flex items-center gap-2">
49-
<Rocket className="size-5" />
50-
Deployments
51-
</CardTitle>
52-
<CardDescription>
53-
All application and compose deployments in one place.
54-
</CardDescription>
55-
</div>
56-
</div>
57-
<Tabs value={tab} onValueChange={setTab} className="w-full min-w-0">
58-
<TabsList className="mt-2">
59-
<TabsTrigger value="deployments">Deployments</TabsTrigger>
60-
<TabsTrigger value="queue">Queue</TabsTrigger>
61-
</TabsList>
62-
<TabsContent value="deployments" className="mt-0 min-w-0 pt-4">
63-
<ShowDeploymentsTable />
64-
</TabsContent>
65-
<TabsContent value="queue" className="mt-0 pt-4">
66-
<ShowQueueTable />
67-
</TabsContent>
68-
</Tabs>
69-
</CardHeader>
70-
</div>
71-
</Card>
72-
</div>
73-
);
3+
export default function DeploymentsRedirect() {
4+
return null;
745
}
756

76-
export default DeploymentsPage;
77-
78-
DeploymentsPage.getLayout = (page: ReactElement) => {
79-
return <DashboardLayout>{page}</DashboardLayout>;
80-
};
81-
827
export async function getServerSideProps(ctx: GetServerSidePropsContext) {
83-
const { user, session } = await validateRequest(ctx.req);
84-
if (!user) {
85-
return {
86-
redirect: {
87-
permanent: false,
88-
destination: "/",
89-
},
90-
};
91-
}
92-
93-
const canView = await hasPermission(
94-
{
95-
user: { id: user.id },
96-
session: { activeOrganizationId: session?.activeOrganizationId || "" },
97-
},
98-
{ deployment: ["read"] },
99-
);
100-
101-
if (!canView) {
102-
return {
103-
redirect: {
104-
permanent: false,
105-
destination: "/dashboard/home",
106-
},
107-
};
108-
}
8+
const destination =
9+
ctx.query.tab === "queue"
10+
? "/dashboard/overview?tab=deployments&subtab=queue"
11+
: "/dashboard/overview?tab=deployments";
10912

11013
return {
111-
props: {},
14+
redirect: {
15+
permanent: false,
16+
destination,
17+
},
11218
};
11319
}

‎apps/dokploy/pages/dashboard/overview.tsx‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useRouter } from "next/router";
55
import type { ReactElement } from "react";
66
import superjson from "superjson";
77
import { ShowOverviewBackups } from "@/components/dashboard/overview/show-overview-backups";
8+
import { ShowOverviewDeployments } from "@/components/dashboard/overview/show-overview-deployments";
89
import { ShowOverviewDomains } from "@/components/dashboard/overview/show-overview-domains";
910
import { ShowOverviewServices } from "@/components/dashboard/overview/show-overview-services";
1011
import { DashboardLayout } from "@/components/layouts/dashboard-layout";
@@ -20,17 +21,19 @@ const Overview = () => {
2021
const canSeeBackups =
2122
!!permissions?.backup.read && !!permissions?.volumeBackup.read;
2223
const canSeeDomains = !!permissions?.domain.read;
24+
const canSeeDeployments = !!permissions?.deployment.read;
2325

2426
const queryTab =
2527
typeof router.query.tab === "string" ? router.query.tab : DEFAULT_TAB;
2628
const activeTab =
2729
(queryTab === "backups" && !canSeeBackups) ||
28-
(queryTab === "domains" && !canSeeDomains)
30+
(queryTab === "domains" && !canSeeDomains) ||
31+
(queryTab === "deployments" && !canSeeDeployments)
2932
? DEFAULT_TAB
3033
: queryTab;
3134

3235
const setTab = (value: string) => {
33-
const { tab: _current, ...query } = router.query;
36+
const { tab: _current, subtab: _subtab, ...query } = router.query;
3437
router.replace(
3538
{
3639
pathname: router.pathname,
@@ -47,6 +50,9 @@ const Overview = () => {
4750
<TabsTrigger value="services">Services</TabsTrigger>
4851
{canSeeBackups && <TabsTrigger value="backups">Backups</TabsTrigger>}
4952
{canSeeDomains && <TabsTrigger value="domains">Domains</TabsTrigger>}
53+
{canSeeDeployments && (
54+
<TabsTrigger value="deployments">Deployments</TabsTrigger>
55+
)}
5056
</TabsList>
5157
<TabsContent value="services">
5258
<ShowOverviewServices />
@@ -61,6 +67,11 @@ const Overview = () => {
6167
<ShowOverviewDomains />
6268
</TabsContent>
6369
)}
70+
{canSeeDeployments && (
71+
<TabsContent value="deployments">
72+
<ShowOverviewDeployments />
73+
</TabsContent>
74+
)}
6475
</Tabs>
6576
);
6677
};

0 commit comments

Comments
 (0)