From 0c5a51c5bf5c0e569f04b3df8af903fb2e953e62 Mon Sep 17 00:00:00 2001 From: MananTank Date: Thu, 13 Feb 2025 23:45:52 +0000 Subject: [PATCH] [TOOL-3243] Dashboard: Add redirect for support old engine import link (#6254) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview This PR enhances the `Page` function in `page.tsx` to handle `searchParams`, allowing for an import URL to trigger a redirect when present. ### Detailed summary - Added `searchParams` to the `Page` function's props. - Used `Promise.all` to await both `params` and `searchParams`. - Implemented a redirect to an import URL if `searchParams.importUrl` is provided. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../(team)/~/engine/(general)/page.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/dashboard/src/app/team/[team_slug]/(team)/~/engine/(general)/page.tsx b/apps/dashboard/src/app/team/[team_slug]/(team)/~/engine/(general)/page.tsx index 200479e0ec5..8058b6fe755 100644 --- a/apps/dashboard/src/app/team/[team_slug]/(team)/~/engine/(general)/page.tsx +++ b/apps/dashboard/src/app/team/[team_slug]/(team)/~/engine/(general)/page.tsx @@ -1,3 +1,4 @@ +import { redirect } from "next/navigation"; import { getAuthToken } from "../../../../../../api/lib/getAuthToken"; import { loginRedirect } from "../../../../../../login/loginRedirect"; import { getEngineInstances } from "../_utils/getEngineInstances"; @@ -10,8 +11,21 @@ export default async function Page(props: { params: Promise<{ team_slug: string; }>; + searchParams: Promise<{ + importUrl?: string; + }>; }) { - const params = await props.params; + const [params, searchParams] = await Promise.all([ + props.params, + props.searchParams, + ]); + + if (searchParams.importUrl) { + redirect( + `/team/${params.team_slug}/~/engine/import?importUrl=${searchParams.importUrl}`, + ); + } + const authToken = await getAuthToken(); if (!authToken) {