-
Notifications
You must be signed in to change notification settings - Fork 46k
fix(frontend): fix builder's page dynamic title #11090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Abhi1992002
wants to merge
3
commits into
dev
Choose a base branch
from
abhimanyuyadav/open-2725-fix-builder-page-title
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
13ea5cb
feat(frontend): refactor BuilderPage and improve metadata generation
Abhi1992002 c8b5032
fix(frontend): await searchParams in metadata generation for accurate…
Abhi1992002 0186db2
Merge branch 'dev' into abhimanyuyadav/open-2725-fix-builder-page-title
Abhi1992002 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
autogpt_platform/frontend/src/app/(platform)/build/components/MainBuilderPage.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"use client"; | ||
|
||
import { useOnboarding } from "@/providers/onboarding/onboarding-provider"; | ||
import FlowEditor from "@/app/(platform)/build/components/legacy-builder/Flow/Flow"; | ||
import { GraphID } from "@/lib/autogpt-server-api/types"; | ||
import { useSearchParams } from "next/navigation"; | ||
import { useEffect } from "react"; | ||
import { Flow } from "./FlowEditor/Flow"; | ||
import { BuilderViewTabs } from "./BuilderViewTabs/BuilderViewTabs"; | ||
import { useBuilderView } from "./BuilderViewTabs/useBuilderViewTabs"; | ||
|
||
function BuilderContent() { | ||
const query = useSearchParams(); | ||
const { completeStep } = useOnboarding(); | ||
|
||
useEffect(() => { | ||
completeStep("BUILDER_OPEN"); | ||
}, [completeStep]); | ||
|
||
const _graphVersion = query.get("flowVersion"); | ||
const graphVersion = _graphVersion ? parseInt(_graphVersion) : undefined; | ||
return ( | ||
<FlowEditor | ||
className="flex h-full w-full" | ||
flowID={(query.get("flowID") as GraphID | null) ?? undefined} | ||
flowVersion={graphVersion} | ||
/> | ||
); | ||
} | ||
|
||
export default function MainBuilderPage() { | ||
const { | ||
isSwitchEnabled, | ||
selectedView, | ||
setSelectedView, | ||
isNewFlowEditorEnabled, | ||
} = useBuilderView(); | ||
|
||
// Switch is temporary, we will remove it once our new flow editor is ready | ||
if (isSwitchEnabled) { | ||
return ( | ||
<div className="relative h-full w-full"> | ||
<BuilderViewTabs value={selectedView} onChange={setSelectedView} /> | ||
{selectedView === "new" ? <Flow /> : <BuilderContent />} | ||
</div> | ||
); | ||
} | ||
|
||
return isNewFlowEditorEnabled ? <Flow /> : <BuilderContent />; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 29 additions & 44 deletions
73
autogpt_platform/frontend/src/app/(platform)/build/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,36 @@ | ||
"use client"; | ||
import { Metadata } from "next"; | ||
import MainBuilderPage from "./components/MainBuilderPage"; | ||
import { getV1GetSpecificGraph } from "@/app/api/__generated__/endpoints/graphs/graphs"; | ||
|
||
import { useOnboarding } from "@/providers/onboarding/onboarding-provider"; | ||
import FlowEditor from "@/app/(platform)/build/components/legacy-builder/Flow/Flow"; | ||
// import LoadingBox from "@/components/__legacy__/ui/loading"; | ||
import { GraphID } from "@/lib/autogpt-server-api/types"; | ||
import { useSearchParams } from "next/navigation"; | ||
import { useEffect } from "react"; | ||
import { Flow } from "./components/FlowEditor/Flow"; | ||
import { BuilderViewTabs } from "./components/BuilderViewTabs/BuilderViewTabs"; | ||
import { useBuilderView } from "./components/BuilderViewTabs/useBuilderViewTabs"; | ||
export async function generateMetadata({ | ||
searchParams, | ||
}: { | ||
searchParams: Promise<{ flowID: string; flowVersion: string }>; | ||
}): Promise<Metadata> { | ||
const { flowID, flowVersion } = await searchParams; | ||
|
||
function BuilderContent() { | ||
const query = useSearchParams(); | ||
const { completeStep } = useOnboarding(); | ||
|
||
useEffect(() => { | ||
completeStep("BUILDER_OPEN"); | ||
}, [completeStep]); | ||
|
||
const _graphVersion = query.get("flowVersion"); | ||
const graphVersion = _graphVersion ? parseInt(_graphVersion) : undefined; | ||
return ( | ||
<FlowEditor | ||
className="flex h-full w-full" | ||
flowID={(query.get("flowID") as GraphID | null) ?? undefined} | ||
flowVersion={graphVersion} | ||
/> | ||
); | ||
} | ||
if (!flowID || !flowVersion) { | ||
return { | ||
title: `Builder - AutoGPT Platform`, | ||
}; | ||
} | ||
|
||
export default function BuilderPage() { | ||
const { | ||
isSwitchEnabled, | ||
selectedView, | ||
setSelectedView, | ||
isNewFlowEditorEnabled, | ||
} = useBuilderView(); | ||
const { data: graph } = await getV1GetSpecificGraph(flowID, { | ||
version: parseInt(flowVersion), | ||
}); | ||
|
||
// Switch is temporary, we will remove it once our new flow editor is ready | ||
if (isSwitchEnabled) { | ||
return ( | ||
<div className="relative h-full w-full"> | ||
<BuilderViewTabs value={selectedView} onChange={setSelectedView} /> | ||
{selectedView === "new" ? <Flow /> : <BuilderContent />} | ||
</div> | ||
); | ||
if (!graph || typeof graph !== "object" || !("name" in graph)) { | ||
return { | ||
title: `Builder - AutoGPT Platform`, | ||
}; | ||
} | ||
|
||
return isNewFlowEditorEnabled ? <Flow /> : <BuilderContent />; | ||
return { | ||
title: `${graph.name} - Builder - AutoGPT Platform`, | ||
}; | ||
} | ||
const BuilderPage = () => { | ||
return <MainBuilderPage />; | ||
}; | ||
|
||
export default BuilderPage; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't this go in
../page.tsx
?