diff --git a/apps/dokploy/components/dashboard/application/general/deploy-application.tsx b/apps/dokploy/components/dashboard/application/general/deploy-application.tsx index f9115c76..252894dd 100644 --- a/apps/dokploy/components/dashboard/application/general/deploy-application.tsx +++ b/apps/dokploy/components/dashboard/application/general/deploy-application.tsx @@ -11,6 +11,7 @@ import { } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import { api } from "@/utils/api"; +import { useRouter } from "next/router"; import { toast } from "sonner"; interface Props { @@ -18,6 +19,7 @@ interface Props { } export const DeployApplication = ({ applicationId }: Props) => { + const router = useRouter(); const { data, refetch } = api.application.one.useQuery( { applicationId, @@ -51,6 +53,9 @@ export const DeployApplication = ({ applicationId }: Props) => { .then(async () => { toast.success("Application deployed succesfully"); await refetch(); + router.push( + `/dashboard/project/${data?.projectId}/services/application/${applicationId}?tab=deployments`, + ); }) .catch(() => { diff --git a/apps/dokploy/components/dashboard/compose/general/deploy-compose.tsx b/apps/dokploy/components/dashboard/compose/general/deploy-compose.tsx index e9d5dfc1..c02a7802 100644 --- a/apps/dokploy/components/dashboard/compose/general/deploy-compose.tsx +++ b/apps/dokploy/components/dashboard/compose/general/deploy-compose.tsx @@ -11,6 +11,7 @@ import { } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import { api } from "@/utils/api"; +import { useRouter } from "next/router"; import { toast } from "sonner"; interface Props { @@ -18,6 +19,7 @@ interface Props { } export const DeployCompose = ({ composeId }: Props) => { + const router = useRouter(); const { data, refetch } = api.compose.one.useQuery( { composeId, @@ -48,9 +50,15 @@ export const DeployCompose = ({ composeId }: Props) => { await refetch(); await deploy({ composeId, - }).catch(() => { - toast.error("Error to deploy Compose"); - }); + }) + .then(async () => { + router.push( + `/dashboard/project/${data?.project.projectId}/services/compose/${composeId}?tab=deployments` + ); + }) + .catch(() => { + toast.error("Error to deploy Compose"); + }); await refetch(); }} diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx index 1682348c..8d3f8df2 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx @@ -44,7 +44,7 @@ import type { import Head from "next/head"; import Link from "next/link"; import { useRouter } from "next/router"; -import React, { useState, type ReactElement } from "react"; +import React, { useState, useEffect, type ReactElement } from "react"; import superjson from "superjson"; type TabState = @@ -62,7 +62,14 @@ const Service = ( const { applicationId, activeTab } = props; const router = useRouter(); const { projectId } = router.query; - const [tab, setSab] = useState(activeTab); + const [tab, setTab] = useState(activeTab); + + useEffect(() => { + if (router.query.tab) { + setTab(router.query.tab as TabState); + } + }, [router.query.tab]); + const { data } = api.application.one.useQuery( { applicationId }, { @@ -191,9 +198,9 @@ const Service = ( defaultValue="general" className="w-full" onValueChange={(e) => { - setSab(e as TabState); + setTab(e as TabState); const newPath = `/dashboard/project/${projectId}/services/application/${applicationId}?tab=${e}`; - router.push(newPath, undefined, { shallow: true }); + router.push(newPath); }} >
diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx index 6b9cae51..69145e8a 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx @@ -38,7 +38,7 @@ import type { import Head from "next/head"; import Link from "next/link"; import { useRouter } from "next/router"; -import React, { useState, type ReactElement } from "react"; +import React, { useState, useEffect, type ReactElement } from "react"; import superjson from "superjson"; type TabState = @@ -55,7 +55,14 @@ const Service = ( const { composeId, activeTab } = props; const router = useRouter(); const { projectId } = router.query; - const [tab, setSab] = useState(activeTab); + const [tab, setTab] = useState(activeTab); + + useEffect(() => { + if (router.query.tab) { + setTab(router.query.tab as TabState); + } + }, [router.query.tab]); + const { data } = api.compose.one.useQuery( { composeId }, { @@ -183,9 +190,9 @@ const Service = ( defaultValue="general" className="w-full" onValueChange={(e) => { - setSab(e as TabState); + setTab(e as TabState); const newPath = `/dashboard/project/${projectId}/services/compose/${composeId}?tab=${e}`; - router.push(newPath, undefined, { shallow: true }); + router.push(newPath); }} >