From 70e08c96eb16a449da4de1cf75c2636510cd1a21 Mon Sep 17 00:00:00 2001 From: croatialu Date: Fri, 11 Jul 2025 11:55:16 +0800 Subject: [PATCH] fix: Add gitlabUrl calculation logic and update link references - Use the useMemo hook to calculate gitlabUrl in the SaveGitlabProvider component. - Update link references to use the dynamically generated gitlabUrl, ensuring links correctly point to the corresponding GitLab repositories. --- .../general/generic/save-gitlab-provider.tsx | 14 ++++++++++++-- apps/dokploy/server/api/routers/gitlab.ts | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/dokploy/components/dashboard/application/general/generic/save-gitlab-provider.tsx b/apps/dokploy/components/dashboard/application/general/generic/save-gitlab-provider.tsx index 3b054fc99..2995e45f3 100644 --- a/apps/dokploy/components/dashboard/application/general/generic/save-gitlab-provider.tsx +++ b/apps/dokploy/components/dashboard/application/general/generic/save-gitlab-provider.tsx @@ -43,7 +43,7 @@ import { api } from "@/utils/api"; import { zodResolver } from "@hookform/resolvers/zod"; import { CheckIcon, ChevronsUpDown, HelpCircle, Plus, X } from "lucide-react"; import Link from "next/link"; -import { useEffect } from "react"; +import { useEffect, useMemo } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; import { z } from "zod"; @@ -96,6 +96,16 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => { const repository = form.watch("repository"); const gitlabId = form.watch("gitlabId"); + const gitlabUrl = useMemo(() => { + const url = gitlabProviders?.find( + (provider) => provider.gitlabId === gitlabId, + )?.gitlabUrl; + + const gitlabUrl = url?.replace(/\/$/, ""); + + return gitlabUrl || "https://gitlab.com"; + }, [gitlabId, gitlabProviders]); + const { data: repositories, isLoading: isLoadingRepositories, @@ -224,7 +234,7 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => { Repository {field.value.owner && field.value.repo && (