From 27521decbdfcc31e7f6c6a06e923a95d9b47ba95 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 4 May 2025 12:29:37 -0600 Subject: [PATCH] Enhance loading state and UI for provider selection in dashboard components - Added loading indicators using the Loader2 icon to improve user experience while fetching provider data in both ShowProviderForm and ShowProviderFormCompose components. - Updated the minimum height of the provider selection messages to enhance visual consistency and user guidance during loading states. - Refactored data fetching logic to include loading states for GitHub, GitLab, Bitbucket, and Gitea providers, ensuring a smoother user interface. --- .../application/general/generic/show.tsx | 53 +++++++++++++++---- .../compose/general/generic/show.tsx | 52 ++++++++++++++---- 2 files changed, 87 insertions(+), 18 deletions(-) diff --git a/apps/dokploy/components/dashboard/application/general/generic/show.tsx b/apps/dokploy/components/dashboard/application/general/generic/show.tsx index 9b9a0ba0..905fe711 100644 --- a/apps/dokploy/components/dashboard/application/general/generic/show.tsx +++ b/apps/dokploy/components/dashboard/application/general/generic/show.tsx @@ -13,7 +13,7 @@ import { import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { api } from "@/utils/api"; -import { GitBranch, UploadCloud } from "lucide-react"; +import { GitBranch, Loader2, UploadCloud } from "lucide-react"; import Link from "next/link"; import { useState } from "react"; import { SaveBitbucketProvider } from "./save-bitbucket-provider"; @@ -34,14 +34,49 @@ interface Props { } export const ShowProviderForm = ({ applicationId }: Props) => { - const { data: githubProviders } = api.github.githubProviders.useQuery(); - const { data: gitlabProviders } = api.gitlab.gitlabProviders.useQuery(); - const { data: bitbucketProviders } = + const { data: githubProviders, isLoading: isLoadingGithub } = + api.github.githubProviders.useQuery(); + const { data: gitlabProviders, isLoading: isLoadingGitlab } = + api.gitlab.gitlabProviders.useQuery(); + const { data: bitbucketProviders, isLoading: isLoadingBitbucket } = api.bitbucket.bitbucketProviders.useQuery(); - const { data: giteaProviders } = api.gitea.giteaProviders.useQuery(); + const { data: giteaProviders, isLoading: isLoadingGitea } = + api.gitea.giteaProviders.useQuery(); const { data: application } = api.application.one.useQuery({ applicationId }); const [tab, setSab] = useState(application?.sourceType || "github"); + + const isLoading = + isLoadingGithub || isLoadingGitlab || isLoadingBitbucket || isLoadingGitea; + + if (isLoading) { + return ( + + + +
+ Provider +

+ Select the source of your code +

+
+
+ +
+
+
+ +
+
+ + Loading providers... +
+
+
+
+ ); + } + return ( @@ -123,7 +158,7 @@ export const ShowProviderForm = ({ applicationId }: Props) => { {githubProviders && githubProviders?.length > 0 ? ( ) : ( -
+
To deploy using GitHub, you need to configure your account @@ -143,7 +178,7 @@ export const ShowProviderForm = ({ applicationId }: Props) => { {gitlabProviders && gitlabProviders?.length > 0 ? ( ) : ( -
+
To deploy using GitLab, you need to configure your account @@ -163,7 +198,7 @@ export const ShowProviderForm = ({ applicationId }: Props) => { {bitbucketProviders && bitbucketProviders?.length > 0 ? ( ) : ( -
+
To deploy using Bitbucket, you need to configure your account @@ -183,7 +218,7 @@ export const ShowProviderForm = ({ applicationId }: Props) => { {giteaProviders && giteaProviders?.length > 0 ? ( ) : ( -
+
To deploy using Gitea, you need to configure your account diff --git a/apps/dokploy/components/dashboard/compose/general/generic/show.tsx b/apps/dokploy/components/dashboard/compose/general/generic/show.tsx index 2ac879e8..afdfbfba 100644 --- a/apps/dokploy/components/dashboard/compose/general/generic/show.tsx +++ b/apps/dokploy/components/dashboard/compose/general/generic/show.tsx @@ -8,7 +8,7 @@ import { import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { api } from "@/utils/api"; -import { CodeIcon, GitBranch } from "lucide-react"; +import { CodeIcon, GitBranch, Loader2 } from "lucide-react"; import Link from "next/link"; import { useState } from "react"; import { ComposeFileEditor } from "../compose-file-editor"; @@ -25,15 +25,49 @@ interface Props { } export const ShowProviderFormCompose = ({ composeId }: Props) => { - const { data: githubProviders } = api.github.githubProviders.useQuery(); - const { data: gitlabProviders } = api.gitlab.gitlabProviders.useQuery(); - const { data: bitbucketProviders } = + const { data: githubProviders, isLoading: isLoadingGithub } = + api.github.githubProviders.useQuery(); + const { data: gitlabProviders, isLoading: isLoadingGitlab } = + api.gitlab.gitlabProviders.useQuery(); + const { data: bitbucketProviders, isLoading: isLoadingBitbucket } = api.bitbucket.bitbucketProviders.useQuery(); - const { data: giteaProviders } = api.gitea.giteaProviders.useQuery(); + const { data: giteaProviders, isLoading: isLoadingGitea } = + api.gitea.giteaProviders.useQuery(); const { data: compose } = api.compose.one.useQuery({ composeId }); const [tab, setSab] = useState(compose?.sourceType || "github"); + const isLoading = + isLoadingGithub || isLoadingGitlab || isLoadingBitbucket || isLoadingGitea; + + if (isLoading) { + return ( + + + +
+ Provider +

+ Select the source of your code +

+
+
+ +
+
+
+ +
+
+ + Loading providers... +
+
+
+
+ ); + } + return ( @@ -108,7 +142,7 @@ export const ShowProviderFormCompose = ({ composeId }: Props) => { {githubProviders && githubProviders?.length > 0 ? ( ) : ( -
+
To deploy using GitHub, you need to configure your account @@ -128,7 +162,7 @@ export const ShowProviderFormCompose = ({ composeId }: Props) => { {gitlabProviders && gitlabProviders?.length > 0 ? ( ) : ( -
+
To deploy using GitLab, you need to configure your account @@ -148,7 +182,7 @@ export const ShowProviderFormCompose = ({ composeId }: Props) => { {bitbucketProviders && bitbucketProviders?.length > 0 ? ( ) : ( -
+
To deploy using Bitbucket, you need to configure your account @@ -168,7 +202,7 @@ export const ShowProviderFormCompose = ({ composeId }: Props) => { {giteaProviders && giteaProviders?.length > 0 ? ( ) : ( -
+
To deploy using Gitea, you need to configure your account