Skip to content

Commit f84c659

Browse files
authored
Merge pull request #3183 from Dokploy/feat/add-last-name-to-profile
feat(user): update user schema to include firstName and lastName fiel…
2 parents a5353e5 + 89cb9c2 commit f84c659

14 files changed

Lines changed: 7001 additions & 56 deletions

File tree

Dockerfile.cloud

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm --filter=@dokploy/server
1616

1717

1818
# Deploy only the dokploy app
19-
ARG NEXT_PUBLIC_UMAMI_HOST
20-
ENV NEXT_PUBLIC_UMAMI_HOST=$NEXT_PUBLIC_UMAMI_HOST
19+
# ARG NEXT_PUBLIC_UMAMI_HOST
20+
# ENV NEXT_PUBLIC_UMAMI_HOST=$NEXT_PUBLIC_UMAMI_HOST
2121

22-
ARG NEXT_PUBLIC_UMAMI_WEBSITE_ID
23-
ENV NEXT_PUBLIC_UMAMI_WEBSITE_ID=$NEXT_PUBLIC_UMAMI_WEBSITE_ID
22+
# ARG NEXT_PUBLIC_UMAMI_WEBSITE_ID
23+
# ENV NEXT_PUBLIC_UMAMI_WEBSITE_ID=$NEXT_PUBLIC_UMAMI_WEBSITE_ID
2424

2525
ARG NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
2626
ENV NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=$NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY

apps/dokploy/__test__/traefik/server/update-server-config.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const baseAdmin: User = {
1818
enablePaidFeatures: false,
1919
allowImpersonation: false,
2020
role: "user",
21+
firstName: "",
22+
lastName: "",
2123
metricsConfig: {
2224
containers: {
2325
refreshRate: 20,
@@ -61,7 +63,6 @@ const baseAdmin: User = {
6163
expirationDate: "",
6264
id: "",
6365
isRegistered: false,
64-
name: "",
6566
createdAt2: new Date().toISOString(),
6667
emailVerified: false,
6768
image: "",

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const ImpersonationBar = () => {
103103
setOpen(false);
104104

105105
toast.success("Successfully impersonating user", {
106-
description: `You are now viewing as ${selectedUser.name || selectedUser.email}`,
106+
description: `You are now viewing as ${`${selectedUser.name} ${selectedUser.lastName}`.trim() || selectedUser.email}`,
107107
});
108108
window.location.reload();
109109
} catch (error) {
@@ -195,7 +195,8 @@ export const ImpersonationBar = () => {
195195
<UserIcon className="mr-2 h-4 w-4 flex-shrink-0" />
196196
<span className="truncate flex flex-col items-start">
197197
<span className="text-sm font-medium">
198-
{selectedUser.name || ""}
198+
{`${selectedUser.name} ${selectedUser.lastName}`.trim() ||
199+
""}
199200
</span>
200201
<span className="text-xs text-muted-foreground">
201202
{selectedUser.email}
@@ -242,7 +243,8 @@ export const ImpersonationBar = () => {
242243
<UserIcon className="h-4 w-4 flex-shrink-0" />
243244
<span className="flex flex-col items-start">
244245
<span className="text-sm font-medium">
245-
{user.name || ""}
246+
{`${user.name} ${user.lastName}`.trim() ||
247+
""}
246248
</span>
247249
<span className="text-xs text-muted-foreground">
248250
{user.email}{user.role}
@@ -283,10 +285,14 @@ export const ImpersonationBar = () => {
283285
<AvatarImage
284286
className="object-cover"
285287
src={data?.user?.image || ""}
286-
alt={data?.user?.name || ""}
288+
alt={
289+
`${data?.user?.firstName} ${data?.user?.lastName}`.trim() ||
290+
""
291+
}
287292
/>
288293
<AvatarFallback>
289-
{data?.user?.name?.slice(0, 2).toUpperCase() || "U"}
294+
{`${data?.user?.firstName?.[0] || ""}${data?.user?.lastName?.[0] || ""}`.toUpperCase() ||
295+
"U"}
290296
</AvatarFallback>
291297
</Avatar>
292298
<div className="flex flex-col gap-1">
@@ -299,7 +305,8 @@ export const ImpersonationBar = () => {
299305
Impersonating
300306
</Badge>
301307
<span className="font-medium">
302-
{data?.user?.name || ""}
308+
{`${data?.user?.firstName} ${data?.user?.lastName}`.trim() ||
309+
""}
303310
</span>
304311
</div>
305312
<div className="flex items-center gap-3 text-sm text-muted-foreground flex-wrap">

apps/dokploy/components/dashboard/settings/profile/profile-form.tsx

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const profileSchema = z.object({
4141
currentPassword: z.string().nullable(),
4242
image: z.string().optional(),
4343
name: z.string().optional(),
44+
lastName: z.string().optional(),
4445
allowImpersonation: z.boolean().optional().default(false),
4546
});
4647

@@ -88,7 +89,8 @@ export const ProfileForm = () => {
8889
image: data?.user?.image || "",
8990
currentPassword: "",
9091
allowImpersonation: data?.user?.allowImpersonation || false,
91-
name: data?.user?.name || "",
92+
name: data?.user?.firstName || "",
93+
lastName: data?.user?.lastName || "",
9294
},
9395
resolver: zodResolver(profileSchema),
9496
});
@@ -102,7 +104,8 @@ export const ProfileForm = () => {
102104
image: data?.user?.image || "",
103105
currentPassword: form.getValues("currentPassword") || "",
104106
allowImpersonation: data?.user?.allowImpersonation,
105-
name: data?.user?.name || "",
107+
name: data?.user?.firstName || "",
108+
lastName: data?.user?.lastName || "",
106109
},
107110
{
108111
keepValues: true,
@@ -127,6 +130,7 @@ export const ProfileForm = () => {
127130
currentPassword: values.currentPassword || undefined,
128131
allowImpersonation: values.allowImpersonation,
129132
name: values.name || undefined,
133+
lastName: values.lastName || undefined,
130134
});
131135
await refetch();
132136
toast.success("Profile Updated");
@@ -136,6 +140,7 @@ export const ProfileForm = () => {
136140
image: values.image,
137141
currentPassword: "",
138142
name: values.name || "",
143+
lastName: values.lastName || "",
139144
});
140145
} catch (error) {
141146
toast.error("Error updating the profile");
@@ -180,9 +185,22 @@ export const ProfileForm = () => {
180185
name="name"
181186
render={({ field }) => (
182187
<FormItem>
183-
<FormLabel>Name</FormLabel>
188+
<FormLabel>First Name</FormLabel>
184189
<FormControl>
185-
<Input placeholder="Name" {...field} />
190+
<Input placeholder="John" {...field} />
191+
</FormControl>
192+
<FormMessage />
193+
</FormItem>
194+
)}
195+
/>
196+
<FormField
197+
control={form.control}
198+
name="lastName"
199+
render={({ field }) => (
200+
<FormItem>
201+
<FormLabel>Last Name</FormLabel>
202+
<FormControl>
203+
<Input placeholder="Doe" {...field} />
186204
</FormControl>
187205
<FormMessage />
188206
</FormItem>
@@ -280,7 +298,7 @@ export const ProfileForm = () => {
280298
<Avatar className="default-avatar h-12 w-12 rounded-full border hover:p-px hover:border-primary transition-transform">
281299
<AvatarFallback className="rounded-lg">
282300
{getFallbackAvatarInitials(
283-
data?.user?.name,
301+
`${data?.user?.firstName} ${data?.user?.lastName}`.trim(),
284302
)}
285303
</AvatarFallback>
286304
</Avatar>

apps/dokploy/components/layouts/user-nav.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ export const UserNav = () => {
4949
alt={data?.user?.image || ""}
5050
/>
5151
<AvatarFallback className="rounded-lg">
52-
{getFallbackAvatarInitials(data?.user?.name)}
52+
{getFallbackAvatarInitials(
53+
`${data?.user?.firstName} ${data?.user?.lastName}`.trim(),
54+
)}
5355
</AvatarFallback>
5456
</Avatar>
5557
<div className="grid flex-1 text-left text-sm leading-tight">
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE "user" RENAME COLUMN "name" TO "firstName";--> statement-breakpoint
2+
ALTER TABLE "user" ADD COLUMN "lastName" text DEFAULT '' NOT NULL;

0 commit comments

Comments
 (0)