From 552f7025c1b321f64d38a0d61f059009333aec22 Mon Sep 17 00:00:00 2001 From: MananTank Date: Wed, 17 Sep 2025 15:58:39 +0000 Subject: [PATCH] Dashboard: Fix Import Engine form submit not working (#8064) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview This PR introduces a dialog for importing engine instances in the `ImportEngineButton` component, enhancing user interaction by managing the dialog state and updating UI elements. ### Detailed summary - Added `useState` to manage the dialog's open state. - Changed navigation from `router.push` to `router.refresh` after import. - Wrapped the dialog in a conditional open state. - Updated the layout and styling of the dialog content and links. - Modified form field styles for better UI consistency. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` ## Summary by CodeRabbit * New Features * Import dialog now closes automatically after a successful import and refreshes the current page. * Added an in-dialog warning beneath the URL field for clearer guidance. * Updated “Get started” link destination. * Style * Redesigned import dialog with improved layout, spacing, rounded content, and a bottom action bar; inputs use card styling. * Refined labels, placeholders, and header padding for clearer readability. --- .../(general)/import/import-engine-dialog.tsx | 76 ++++++++++--------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx index 04ff3953eec..1ff478e9e67 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/(general)/import/import-engine-dialog.tsx @@ -8,6 +8,7 @@ import { ExternalLinkIcon, } from "lucide-react"; import Link from "next/link"; +import { useState } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; import { z } from "zod"; @@ -17,7 +18,6 @@ import { Dialog, DialogContent, DialogDescription, - DialogFooter, DialogHeader, DialogTitle, DialogTrigger, @@ -70,6 +70,7 @@ export function ImportEngineButton(props: { teamSlug: string; projectSlug: string; }) { + const [isOpen, setIsOpen] = useState(false); const router = useDashboardRouter(); const form = useForm({ resolver: zodResolver(formSchema), @@ -82,7 +83,7 @@ export function ImportEngineButton(props: { const importMutation = useMutation({ mutationFn: async (importParams: ImportEngineParams) => { await importEngine({ ...importParams, teamIdOrSlug: props.teamSlug }); - router.push(`/team/${props.teamSlug}/${props.projectSlug}/engine`); + router.refresh(); }, }); @@ -90,6 +91,7 @@ export function ImportEngineButton(props: { try { await importMutation.mutateAsync(data); toast.success("Engine imported successfully"); + setIsOpen(false); } catch (e) { const message = e instanceof Error ? e.message : undefined; toast.error( @@ -102,42 +104,40 @@ export function ImportEngineButton(props: { }; return ( -
- - - - - + + + + - - + + + + Import Engine Instance Import an Engine instance hosted on your infrastructure. -
-
- - Get help setting up Engine for free - - -
+
+ + Get help setting up Engine for free + + -
+
Name URL
- - - - -
- - + + + + +
); }