From 891dc840f5631e4288aab246e8c4a503ba55a94d Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Tue, 18 Mar 2025 21:11:50 -0600 Subject: [PATCH 1/2] feat(cluster): enhance node management UI with loading indicators and improved tab content - Added loading indicators in AddManager and AddWorker components to enhance user experience during data fetching. - Updated AddNode component to include overflow handling for tab content. - Renamed "Show Nodes" to "Show Swarm Nodes" in ShowNodesModal for clarity. --- .../settings/cluster/nodes/add-node.tsx | 4 +- .../cluster/nodes/manager/add-manager.tsx | 101 ++++++++++-------- .../cluster/nodes/show-nodes-modal.tsx | 2 +- .../cluster/nodes/workers/add-worker.tsx | 97 +++++++++-------- 4 files changed, 108 insertions(+), 96 deletions(-) diff --git a/apps/dokploy/components/dashboard/settings/cluster/nodes/add-node.tsx b/apps/dokploy/components/dashboard/settings/cluster/nodes/add-node.tsx index eaa9851fc..a59681ba0 100644 --- a/apps/dokploy/components/dashboard/settings/cluster/nodes/add-node.tsx +++ b/apps/dokploy/components/dashboard/settings/cluster/nodes/add-node.tsx @@ -56,10 +56,10 @@ export const AddNode = ({ serverId }: Props) => { Worker Manager - + - + diff --git a/apps/dokploy/components/dashboard/settings/cluster/nodes/manager/add-manager.tsx b/apps/dokploy/components/dashboard/settings/cluster/nodes/manager/add-manager.tsx index 055c3f1cc..6cb8f257c 100644 --- a/apps/dokploy/components/dashboard/settings/cluster/nodes/manager/add-manager.tsx +++ b/apps/dokploy/components/dashboard/settings/cluster/nodes/manager/add-manager.tsx @@ -6,7 +6,7 @@ import { } from "@/components/ui/dialog"; import { api } from "@/utils/api"; import copy from "copy-to-clipboard"; -import { CopyIcon } from "lucide-react"; +import { CopyIcon, Loader2 } from "lucide-react"; import { toast } from "sonner"; interface Props { @@ -14,56 +14,63 @@ interface Props { } export const AddManager = ({ serverId }: Props) => { - const { data } = api.cluster.addManager.useQuery({ serverId }); + const { data, isLoading } = api.cluster.addManager.useQuery({ serverId }); return ( <> -
- - - Add a new manager - Add a new manager - -
- 1. Go to your new server and run the following command - - curl https://get.docker.com | sh -s -- --version {data?.version} - - -
+ + + Add a new manager + Add a new manager + + {isLoading ? ( + + ) : ( + <> +
+ + 1. Go to your new server and run the following command + + + curl https://get.docker.com | sh -s -- --version {data?.version} + + +
-
- - 2. Run the following command to add the node(manager) to your - cluster - - - {data?.command} - - -
-
-
+
+ + 2. Run the following command to add the node(manager) to your + cluster + + + + {data?.command} + + +
+ + )} + ); }; diff --git a/apps/dokploy/components/dashboard/settings/cluster/nodes/show-nodes-modal.tsx b/apps/dokploy/components/dashboard/settings/cluster/nodes/show-nodes-modal.tsx index 32339e668..82e6e1f9a 100644 --- a/apps/dokploy/components/dashboard/settings/cluster/nodes/show-nodes-modal.tsx +++ b/apps/dokploy/components/dashboard/settings/cluster/nodes/show-nodes-modal.tsx @@ -17,7 +17,7 @@ export const ShowNodesModal = ({ serverId }: Props) => { className="w-full cursor-pointer " onSelect={(e) => e.preventDefault()} > - Show Nodes + Show Swarm Nodes diff --git a/apps/dokploy/components/dashboard/settings/cluster/nodes/workers/add-worker.tsx b/apps/dokploy/components/dashboard/settings/cluster/nodes/workers/add-worker.tsx index 05f9838e7..3dec559e2 100644 --- a/apps/dokploy/components/dashboard/settings/cluster/nodes/workers/add-worker.tsx +++ b/apps/dokploy/components/dashboard/settings/cluster/nodes/workers/add-worker.tsx @@ -6,7 +6,7 @@ import { } from "@/components/ui/dialog"; import { api } from "@/utils/api"; import copy from "copy-to-clipboard"; -import { CopyIcon } from "lucide-react"; +import { CopyIcon, Loader2 } from "lucide-react"; import { toast } from "sonner"; interface Props { @@ -14,54 +14,59 @@ interface Props { } export const AddWorker = ({ serverId }: Props) => { - const { data } = api.cluster.addWorker.useQuery({ serverId }); + const { data, isLoading } = api.cluster.addWorker.useQuery({ serverId }); return ( -
- - - Add a new worker - Add a new worker - -
- 1. Go to your new server and run the following command - - curl https://get.docker.com | sh -s -- --version {data?.version} - - -
+ + + Add a new worker + Add a new worker + + {isLoading ? ( + + ) : ( + <> +
+ 1. Go to your new server and run the following command + + curl https://get.docker.com | sh -s -- --version {data?.version} + + +
-
- - 2. Run the following command to add the node(worker) to your cluster - +
+ + 2. Run the following command to add the node(worker) to your + cluster + - - {data?.command} - - -
- -
+ + {data?.command} + + +
+ + )} + ); }; From 7123b9b109df2388ce36dda76f23e3c6425370dd Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Tue, 18 Mar 2025 21:17:11 -0600 Subject: [PATCH 2/2] feat(cluster): add error handling in AddManager and AddWorker components - Integrated error handling in AddManager and AddWorker components to display error messages using AlertBlock when data fetching fails. - Updated API query hooks to include error and isError states for improved user feedback during data operations. --- .../settings/cluster/nodes/manager/add-manager.tsx | 6 +++++- .../dashboard/settings/cluster/nodes/workers/add-worker.tsx | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/dokploy/components/dashboard/settings/cluster/nodes/manager/add-manager.tsx b/apps/dokploy/components/dashboard/settings/cluster/nodes/manager/add-manager.tsx index 6cb8f257c..bb2064d4e 100644 --- a/apps/dokploy/components/dashboard/settings/cluster/nodes/manager/add-manager.tsx +++ b/apps/dokploy/components/dashboard/settings/cluster/nodes/manager/add-manager.tsx @@ -1,3 +1,4 @@ +import { AlertBlock } from "@/components/shared/alert-block"; import { CardContent } from "@/components/ui/card"; import { DialogDescription, @@ -14,7 +15,9 @@ interface Props { } export const AddManager = ({ serverId }: Props) => { - const { data, isLoading } = api.cluster.addManager.useQuery({ serverId }); + const { data, isLoading, error, isError } = api.cluster.addManager.useQuery({ + serverId, + }); return ( <> @@ -23,6 +26,7 @@ export const AddManager = ({ serverId }: Props) => { Add a new manager Add a new manager + {isError && {error?.message}} {isLoading ? ( ) : ( diff --git a/apps/dokploy/components/dashboard/settings/cluster/nodes/workers/add-worker.tsx b/apps/dokploy/components/dashboard/settings/cluster/nodes/workers/add-worker.tsx index 3dec559e2..2623081bb 100644 --- a/apps/dokploy/components/dashboard/settings/cluster/nodes/workers/add-worker.tsx +++ b/apps/dokploy/components/dashboard/settings/cluster/nodes/workers/add-worker.tsx @@ -1,3 +1,4 @@ +import { AlertBlock } from "@/components/shared/alert-block"; import { CardContent } from "@/components/ui/card"; import { DialogDescription, @@ -14,7 +15,9 @@ interface Props { } export const AddWorker = ({ serverId }: Props) => { - const { data, isLoading } = api.cluster.addWorker.useQuery({ serverId }); + const { data, isLoading, error, isError } = api.cluster.addWorker.useQuery({ + serverId, + }); return ( @@ -22,6 +25,7 @@ export const AddWorker = ({ serverId }: Props) => { Add a new worker Add a new worker + {isError && {error?.message}} {isLoading ? ( ) : (