Skip to content

Commit 33532d3

Browse files
committed
refactor: update whitelabeling hooks and API usage for improved access control and consistency
1 parent a6999b1 commit 33532d3

13 files changed

Lines changed: 108 additions & 32 deletions

File tree

apps/dokploy/components/dashboard/impersonation/impersonation-bar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ import {
4545
import { authClient } from "@/lib/auth-client";
4646
import { cn } from "@/lib/utils";
4747
import { api } from "@/utils/api";
48-
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
48+
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
4949

5050
type User = typeof authClient.$Infer.Session.user;
5151

5252
export const ImpersonationBar = () => {
53-
const { config: whitelabeling } = useWhitelabelingPublic();
53+
const { config: whitelabeling } = useWhitelabeling();
5454
const [users, setUsers] = useState<User[]>([]);
5555
const [selectedUser, setSelectedUser] = useState<User | null>(null);
5656
const [isImpersonating, setIsImpersonating] = useState(false);

apps/dokploy/components/layouts/side.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import {
2323
Loader2,
2424
LogIn,
2525
type LucideIcon,
26-
Palette,
2726
Package,
27+
Palette,
2828
PieChart,
2929
Rocket,
3030
Server,
@@ -895,10 +895,10 @@ export default function Page({ children }: Props) {
895895
const pathname = usePathname();
896896
const { data: auth } = api.user.get.useQuery();
897897
const { data: dokployVersion } = api.settings.getDokployVersion.useQuery();
898-
const { data: whitelabeling } = api.whitelabeling.getPublic.useQuery(
899-
undefined,
900-
{ staleTime: 5 * 60 * 1000, refetchOnWindowFocus: false },
901-
);
898+
const { data: whitelabeling } = api.whitelabeling.get.useQuery(undefined, {
899+
staleTime: 5 * 60 * 1000,
900+
refetchOnWindowFocus: false,
901+
});
902902

903903
const includesProjects = pathname?.includes("/dashboard/project");
904904
const { data: isCloud } = api.settings.isCloud.useQuery();

apps/dokploy/components/proprietary/whitelabeling/whitelabeling-settings.tsx

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const formSchema = z.object({
3737
faviconUrl: z.string(),
3838
customCss: z.string(),
3939
loginLogoUrl: z.string(),
40+
supportUrl: z.string(),
41+
docsUrl: z.string(),
4042
errorPageTitle: z.string(),
4143
errorPageDescription: z.string(),
4244
metaTitle: z.string(),
@@ -173,6 +175,8 @@ export function WhitelabelingSettings() {
173175
faviconUrl: "",
174176
customCss: "",
175177
loginLogoUrl: "",
178+
supportUrl: "",
179+
docsUrl: "",
176180
errorPageTitle: "",
177181
errorPageDescription: "",
178182
metaTitle: "",
@@ -190,6 +194,8 @@ export function WhitelabelingSettings() {
190194
faviconUrl: data.faviconUrl ?? "",
191195
customCss: data.customCss ?? "",
192196
loginLogoUrl: data.loginLogoUrl ?? "",
197+
supportUrl: data.supportUrl ?? "",
198+
docsUrl: data.docsUrl ?? "",
193199
errorPageTitle: data.errorPageTitle ?? "",
194200
errorPageDescription: data.errorPageDescription ?? "",
195201
metaTitle: data.metaTitle ?? "",
@@ -219,8 +225,8 @@ export function WhitelabelingSettings() {
219225
primaryColor: null,
220226
customCss: values.customCss || null,
221227
loginLogoUrl: values.loginLogoUrl || null,
222-
supportUrl: null,
223-
docsUrl: null,
228+
supportUrl: values.supportUrl || null,
229+
docsUrl: values.docsUrl || null,
224230
errorPageTitle: values.errorPageTitle || null,
225231
errorPageDescription: values.errorPageDescription || null,
226232
metaTitle: values.metaTitle || null,
@@ -231,6 +237,7 @@ export function WhitelabelingSettings() {
231237
toast.success("Whitelabeling settings updated");
232238
await refetch();
233239
await utils.whitelabeling.getPublic.invalidate();
240+
await utils.whitelabeling.get.invalidate();
234241
})
235242
.catch((error) => {
236243
toast.error(
@@ -245,6 +252,7 @@ export function WhitelabelingSettings() {
245252
toast.success("Whitelabeling settings reset to defaults");
246253
await refetch();
247254
await utils.whitelabeling.getPublic.invalidate();
255+
await utils.whitelabeling.get.invalidate();
248256
})
249257
.catch((error) => {
250258
toast.error(error?.message || "Failed to reset whitelabeling settings");
@@ -423,9 +431,9 @@ export function WhitelabelingSettings() {
423431
{/* Metadata & Links Section */}
424432
<Card className="bg-transparent">
425433
<CardHeader>
426-
<CardTitle>Metadata</CardTitle>
434+
<CardTitle>Metadata & Links</CardTitle>
427435
<CardDescription>
428-
Customize the page title and footer text.
436+
Customize the page title, footer text, and sidebar links.
429437
</CardDescription>
430438
</CardHeader>
431439
<CardContent className="flex flex-col gap-4">
@@ -462,6 +470,46 @@ export function WhitelabelingSettings() {
462470
</FormItem>
463471
)}
464472
/>
473+
474+
<FormField
475+
control={form.control}
476+
name="supportUrl"
477+
render={({ field }) => (
478+
<FormItem>
479+
<FormLabel>Support URL</FormLabel>
480+
<FormControl>
481+
<Input
482+
placeholder="https://support.example.com"
483+
{...field}
484+
/>
485+
</FormControl>
486+
<FormDescription>
487+
Custom URL for the "Support" link in the sidebar.
488+
</FormDescription>
489+
<FormMessage />
490+
</FormItem>
491+
)}
492+
/>
493+
494+
<FormField
495+
control={form.control}
496+
name="docsUrl"
497+
render={({ field }) => (
498+
<FormItem>
499+
<FormLabel>Documentation URL</FormLabel>
500+
<FormControl>
501+
<Input
502+
placeholder="https://docs.example.com"
503+
{...field}
504+
/>
505+
</FormControl>
506+
<FormDescription>
507+
Custom URL for the "Documentation" link in the sidebar.
508+
</FormDescription>
509+
<FormMessage />
510+
</FormItem>
511+
)}
512+
/>
465513
</CardContent>
466514
</Card>
467515

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ import {
9898
import { cn } from "@/lib/utils";
9999
import { appRouter } from "@/server/api/root";
100100
import { api } from "@/utils/api";
101-
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
101+
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
102102

103103
export type Services = {
104104
serverId?: string | null;
@@ -371,7 +371,7 @@ const EnvironmentPage = (
371371
{ projectId: selectedTargetProject },
372372
{ enabled: !!selectedTargetProject },
373373
);
374-
const { config: whitelabeling } = useWhitelabelingPublic();
374+
const { config: whitelabeling } = useWhitelabeling();
375375
const appName = whitelabeling?.appName || "Dokploy";
376376

377377
const emptyServices =

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import {
5656
import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
5757
import { appRouter } from "@/server/api/root";
5858
import { api } from "@/utils/api";
59-
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
59+
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
6060

6161
type TabState =
6262
| "projects"
@@ -96,7 +96,7 @@ const Service = (
9696
const { data: environments } = api.environment.byProjectId.useQuery({
9797
projectId: data?.environment?.project?.projectId || "",
9898
});
99-
const { config: whitelabeling } = useWhitelabelingPublic();
99+
const { config: whitelabeling } = useWhitelabeling();
100100
const appName = whitelabeling?.appName || "Dokploy";
101101
const environmentDropdownItems =
102102
environments?.map((env) => ({

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import {
5252
import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
5353
import { appRouter } from "@/server/api/root";
5454
import { api } from "@/utils/api";
55-
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
55+
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
5656

5757
type TabState =
5858
| "projects"
@@ -85,7 +85,7 @@ const Service = (
8585
const { data: environments } = api.environment.byProjectId.useQuery({
8686
projectId: data?.environment?.projectId || "",
8787
});
88-
const { config: whitelabeling } = useWhitelabelingPublic();
88+
const { config: whitelabeling } = useWhitelabeling();
8989
const appName = whitelabeling?.appName || "Dokploy";
9090
const environmentDropdownItems =
9191
environments?.map((env) => ({

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
4545
import { cn } from "@/lib/utils";
4646
import { appRouter } from "@/server/api/root";
4747
import { api } from "@/utils/api";
48-
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
48+
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
4949

5050
type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced";
5151

@@ -66,7 +66,7 @@ const Mariadb = (
6666
const { data: environments } = api.environment.byProjectId.useQuery({
6767
projectId: data?.environment?.projectId || "",
6868
});
69-
const { config: whitelabeling } = useWhitelabelingPublic();
69+
const { config: whitelabeling } = useWhitelabeling();
7070
const appName = whitelabeling?.appName || "Dokploy";
7171
const environmentDropdownItems =
7272
environments?.map((env) => ({

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
4545
import { cn } from "@/lib/utils";
4646
import { appRouter } from "@/server/api/root";
4747
import { api } from "@/utils/api";
48-
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
48+
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
4949

5050
type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced";
5151

@@ -65,7 +65,7 @@ const Mongo = (
6565
const { data: environments } = api.environment.byProjectId.useQuery({
6666
projectId: data?.environment?.projectId || "",
6767
});
68-
const { config: whitelabeling } = useWhitelabelingPublic();
68+
const { config: whitelabeling } = useWhitelabeling();
6969
const appName = whitelabeling?.appName || "Dokploy";
7070
const environmentDropdownItems =
7171
environments?.map((env) => ({

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
4545
import { cn } from "@/lib/utils";
4646
import { appRouter } from "@/server/api/root";
4747
import { api } from "@/utils/api";
48-
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
48+
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
4949

5050
type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced";
5151

@@ -64,7 +64,7 @@ const MySql = (
6464
const { data: environments } = api.environment.byProjectId.useQuery({
6565
projectId: data?.environment?.projectId || "",
6666
});
67-
const { config: whitelabeling } = useWhitelabelingPublic();
67+
const { config: whitelabeling } = useWhitelabeling();
6868
const appName = whitelabeling?.appName || "Dokploy";
6969
const environmentDropdownItems =
7070
environments?.map((env) => ({

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
4545
import { cn } from "@/lib/utils";
4646
import { appRouter } from "@/server/api/root";
4747
import { api } from "@/utils/api";
48-
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
48+
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
4949

5050
type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced";
5151

@@ -64,7 +64,7 @@ const Postgresql = (
6464
const { data: environments } = api.environment.byProjectId.useQuery({
6565
projectId: data?.environment?.projectId || "",
6666
});
67-
const { config: whitelabeling } = useWhitelabelingPublic();
67+
const { config: whitelabeling } = useWhitelabeling();
6868
const appName = whitelabeling?.appName || "Dokploy";
6969
const environmentDropdownItems =
7070
environments?.map((env) => ({

0 commit comments

Comments
 (0)