Skip to content

Commit 8db1250

Browse files
committed
fix(ui): improve select component behavior and styling across various providers
- Added a check to prevent empty values from being processed in the onValueChange handler for Bitbucket, Gitea, GitHub, and GitLab providers. - Removed unnecessary defaultValue prop from Select components to streamline the code. - Updated button styles to remove background color for better consistency across the UI. - Enhanced volume backup selection to display a message when no volumes are found. This update enhances user experience by ensuring that empty selections are handled gracefully and improves the overall visual consistency of the UI components.
1 parent 2440e8f commit 8db1250

29 files changed

Lines changed: 451 additions & 124 deletions

‎apps/dokploy/components/dashboard/application/general/generic/save-bitbucket-provider.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
188188
<FormLabel>Bitbucket Account</FormLabel>
189189
<Select
190190
onValueChange={(value) => {
191+
if (!value) {
192+
return;
193+
}
191194
field.onChange(value);
192195
form.setValue("repository", {
193196
owner: "",
@@ -196,7 +199,6 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
196199
});
197200
form.setValue("branch", "");
198201
}}
199-
defaultValue={field.value}
200202
value={field.value}
201203
>
202204
<FormControl>
@@ -245,7 +247,7 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
245247
<Button
246248
variant="outline"
247249
className={cn(
248-
"w-full justify-between bg-input!",
250+
"w-full justify-between",
249251
!field.value && "text-muted-foreground",
250252
)}
251253
>
@@ -333,7 +335,7 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
333335
<Button
334336
variant="outline"
335337
className={cn(
336-
" w-full justify-between bg-input!",
338+
" w-full justify-between",
337339
!field.value && "text-muted-foreground",
338340
)}
339341
>

‎apps/dokploy/components/dashboard/application/general/generic/save-gitea-provider.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,16 @@ export const SaveGiteaProvider = ({ applicationId }: Props) => {
201201
<FormLabel>Gitea Account</FormLabel>
202202
<Select
203203
onValueChange={(value) => {
204+
if (!value) {
205+
return;
206+
}
204207
field.onChange(value);
205208
form.setValue("repository", {
206209
owner: "",
207210
repo: "",
208211
});
209212
form.setValue("branch", "");
210213
}}
211-
defaultValue={field.value}
212214
value={field.value}
213215
>
214216
<FormControl>
@@ -258,7 +260,7 @@ export const SaveGiteaProvider = ({ applicationId }: Props) => {
258260
<Button
259261
variant="outline"
260262
className={cn(
261-
"w-full justify-between bg-input!",
263+
"w-full justify-between",
262264
!field.value && "text-muted-foreground",
263265
)}
264266
>
@@ -353,7 +355,7 @@ export const SaveGiteaProvider = ({ applicationId }: Props) => {
353355
<Button
354356
variant="outline"
355357
className={cn(
356-
" w-full justify-between bg-input!",
358+
" w-full justify-between",
357359
!field.value && "text-muted-foreground",
358360
)}
359361
>

‎apps/dokploy/components/dashboard/application/general/generic/save-github-provider.tsx‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
177177
<FormLabel>Github Account</FormLabel>
178178
<Select
179179
onValueChange={(value) => {
180+
if (!value) {
181+
return;
182+
}
180183
field.onChange(value);
181184
form.setValue("repository", {
182185
owner: "",
@@ -189,7 +192,14 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
189192
>
190193
<FormControl>
191194
<SelectTrigger>
192-
<SelectValue placeholder="Select a Github Account" />
195+
<SelectValue placeholder="Select a Github Account">
196+
{
197+
githubProviders?.find(
198+
(githubProvider) =>
199+
githubProvider.githubId === field.value,
200+
)?.gitProvider.name
201+
}
202+
</SelectValue>
193203
</SelectTrigger>
194204
</FormControl>
195205
<SelectContent>
@@ -233,7 +243,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
233243
<Button
234244
variant="outline"
235245
className={cn(
236-
"w-full justify-between bg-input!",
246+
"w-full justify-between",
237247
!field.value && "text-muted-foreground",
238248
)}
239249
>
@@ -243,7 +253,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
243253
? "Loading...."
244254
: (repositories?.find(
245255
(repo) => repo.name === field.value.repo,
246-
)?.name ?? "Select repository")}
256+
)?.name ?? field.value.repo)}
247257

248258
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
249259
</Button>
@@ -320,16 +330,16 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
320330
<Button
321331
variant="outline"
322332
className={cn(
323-
" w-full justify-between bg-input!",
333+
" w-full justify-between",
324334
!field.value && "text-muted-foreground",
325335
)}
326336
>
327337
{status === "pending" && fetchStatus === "fetching"
328338
? "Loading...."
329339
: field.value
330-
? branches?.find(
340+
? (branches?.find(
331341
(branch) => branch.name === field.value,
332-
)?.name
342+
)?.name ?? field.value)
333343
: "Select branch"}
334344
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
335345
</Button>

‎apps/dokploy/components/dashboard/application/general/generic/save-gitlab-provider.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => {
196196
<FormLabel>Gitlab Account</FormLabel>
197197
<Select
198198
onValueChange={(value) => {
199+
if (!value) {
200+
return;
201+
}
199202
field.onChange(value);
200203
form.setValue("repository", {
201204
owner: "",
@@ -205,7 +208,6 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => {
205208
});
206209
form.setValue("branch", "");
207210
}}
208-
defaultValue={field.value}
209211
value={field.value}
210212
>
211213
<FormControl>
@@ -254,7 +256,7 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => {
254256
<Button
255257
variant="outline"
256258
className={cn(
257-
"w-full justify-between bg-input!",
259+
"w-full justify-between",
258260
!field.value && "text-muted-foreground",
259261
)}
260262
>
@@ -351,7 +353,7 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => {
351353
<Button
352354
variant="outline"
353355
className={cn(
354-
" w-full justify-between bg-input!",
356+
" w-full justify-between",
355357
!field.value && "text-muted-foreground",
356358
)}
357359
>

‎apps/dokploy/components/dashboard/application/schedules/handle-schedules.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ export const HandleSchedules = ({ id, scheduleId, scheduleType }: Props) => {
531531
<Button
532532
variant="outline"
533533
className={cn(
534-
"w-full justify-between bg-input!",
534+
"w-full justify-between",
535535
!field.value && "text-muted-foreground",
536536
)}
537537
>

‎apps/dokploy/components/dashboard/application/volume-backups/handle-volume-backups.tsx‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,11 +507,17 @@ export const HandleVolumeBackups = ({
507507
</SelectTrigger>
508508
</FormControl>
509509
<SelectContent>
510-
{mounts?.map((mount) => (
511-
<SelectItem key={mount.Name} value={mount.Name || ""}>
512-
{mount.Name}
510+
{mounts && mounts.length > 0 ? (
511+
mounts.map((mount) => (
512+
<SelectItem key={mount.Name} value={mount.Name || ""}>
513+
{mount.Name}
514+
</SelectItem>
515+
))
516+
) : (
517+
<SelectItem value="none" disabled>
518+
No volumes found
513519
</SelectItem>
514-
))}
520+
)}
515521
</SelectContent>
516522
</Select>
517523
<FormDescription>

‎apps/dokploy/components/dashboard/application/volume-backups/restore-volume-backups.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export const RestoreVolumeBackups = ({ id, type, serverId }: Props) => {
181181
<Button
182182
variant="outline"
183183
className={cn(
184-
"w-full justify-between bg-input!",
184+
"w-full justify-between",
185185
!field.value && "text-muted-foreground",
186186
)}
187187
>
@@ -263,7 +263,7 @@ export const RestoreVolumeBackups = ({ id, type, serverId }: Props) => {
263263
<Button
264264
variant="outline"
265265
className={cn(
266-
"w-full justify-between bg-input!",
266+
"w-full justify-between",
267267
!field.value && "text-muted-foreground",
268268
)}
269269
>

‎apps/dokploy/components/dashboard/compose/general/generic/save-bitbucket-provider-compose.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ export const SaveBitbucketProviderCompose = ({ composeId }: Props) => {
190190
<FormLabel>Bitbucket Account</FormLabel>
191191
<Select
192192
onValueChange={(value) => {
193+
if (!value) {
194+
return;
195+
}
193196
field.onChange(value);
194197
form.setValue("repository", {
195198
owner: "",
@@ -198,7 +201,6 @@ export const SaveBitbucketProviderCompose = ({ composeId }: Props) => {
198201
});
199202
form.setValue("branch", "");
200203
}}
201-
defaultValue={field.value}
202204
value={field.value}
203205
>
204206
<FormControl>
@@ -247,7 +249,7 @@ export const SaveBitbucketProviderCompose = ({ composeId }: Props) => {
247249
<Button
248250
variant="outline"
249251
className={cn(
250-
"w-full justify-between bg-input!",
252+
"w-full justify-between",
251253
!field.value && "text-muted-foreground",
252254
)}
253255
>
@@ -335,7 +337,7 @@ export const SaveBitbucketProviderCompose = ({ composeId }: Props) => {
335337
<Button
336338
variant="outline"
337339
className={cn(
338-
" w-full justify-between bg-input!",
340+
" w-full justify-between",
339341
!field.value && "text-muted-foreground",
340342
)}
341343
>

‎apps/dokploy/components/dashboard/compose/general/generic/save-gitea-provider-compose.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,16 @@ export const SaveGiteaProviderCompose = ({ composeId }: Props) => {
188188
<FormLabel>Gitea Account</FormLabel>
189189
<Select
190190
onValueChange={(value) => {
191+
if (!value) {
192+
return;
193+
}
191194
field.onChange(value);
192195
form.setValue("repository", {
193196
owner: "",
194197
repo: "",
195198
});
196199
form.setValue("branch", "");
197200
}}
198-
defaultValue={field.value}
199201
value={field.value}
200202
>
201203
<FormControl>
@@ -244,7 +246,7 @@ export const SaveGiteaProviderCompose = ({ composeId }: Props) => {
244246
<Button
245247
variant="outline"
246248
className={cn(
247-
"w-full justify-between bg-input!",
249+
"w-full justify-between",
248250
!field.value && "text-muted-foreground",
249251
)}
250252
>
@@ -331,7 +333,7 @@ export const SaveGiteaProviderCompose = ({ composeId }: Props) => {
331333
<Button
332334
variant="outline"
333335
className={cn(
334-
"w-full justify-between bg-input!",
336+
"w-full justify-between",
335337
!field.value && "text-muted-foreground",
336338
)}
337339
>

‎apps/dokploy/components/dashboard/compose/general/generic/save-github-provider-compose.tsx‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export const SaveGithubProviderCompose = ({ composeId }: Props) => {
138138
enableSubmodules: data.enableSubmodules ?? false,
139139
});
140140
}
141-
}, [form.reset, data?.composeId, form]);
141+
}, [form.reset, data]);
142142

143143
const onSubmit = async (data: GithubProvider) => {
144144
await mutateAsync({
@@ -179,14 +179,16 @@ export const SaveGithubProviderCompose = ({ composeId }: Props) => {
179179
<FormLabel>Github Account</FormLabel>
180180
<Select
181181
onValueChange={(value) => {
182+
if (!value) {
183+
return;
184+
}
182185
field.onChange(value);
183186
form.setValue("repository", {
184187
owner: "",
185188
repo: "",
186189
});
187190
form.setValue("branch", "");
188191
}}
189-
defaultValue={field.value}
190192
value={field.value}
191193
>
192194
<FormControl>
@@ -234,7 +236,7 @@ export const SaveGithubProviderCompose = ({ composeId }: Props) => {
234236
<Button
235237
variant="outline"
236238
className={cn(
237-
"w-full justify-between bg-input!",
239+
"w-full justify-between",
238240
!field.value && "text-muted-foreground",
239241
)}
240242
>
@@ -244,7 +246,7 @@ export const SaveGithubProviderCompose = ({ composeId }: Props) => {
244246
? "Loading...."
245247
: (repositories?.find(
246248
(repo) => repo.name === field.value.repo,
247-
)?.name ?? "Select repository")}
249+
)?.name ?? field.value.repo)}
248250

249251
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
250252
</Button>
@@ -321,16 +323,16 @@ export const SaveGithubProviderCompose = ({ composeId }: Props) => {
321323
<Button
322324
variant="outline"
323325
className={cn(
324-
" w-full justify-between bg-input!",
326+
" w-full justify-between",
325327
!field.value && "text-muted-foreground",
326328
)}
327329
>
328330
{status === "pending" && fetchStatus === "fetching"
329331
? "Loading...."
330332
: field.value
331-
? branches?.find(
333+
? (branches?.find(
332334
(branch) => branch.name === field.value,
333-
)?.name
335+
)?.name ?? field.value)
334336
: "Select branch"}
335337
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
336338
</Button>

0 commit comments

Comments
 (0)