-
Notifications
You must be signed in to change notification settings - Fork 46.2k
fix(frontend): hide better chat link if not enabled #11648
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,6 @@ import { PreviewBanner } from "@/components/layout/Navbar/components/PreviewBann | |
| import { useBreakpoint } from "@/lib/hooks/useBreakpoint"; | ||
| import { useSupabase } from "@/lib/supabase/hooks/useSupabase"; | ||
| import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag"; | ||
| import { useMemo } from "react"; | ||
| import { okData } from "@/app/api/helpers"; | ||
| import { getAccountMenuItems, loggedInLinks, loggedOutLinks } from "../helpers"; | ||
| import { AccountMenu } from "./AccountMenu/AccountMenu"; | ||
|
|
@@ -41,11 +40,6 @@ export function NavbarView({ isLoggedIn, previewBranchName }: NavbarViewProps) { | |
| const { isUserLoading } = useSupabase(); | ||
| const isLoadingProfile = isProfileLoading || isUserLoading; | ||
|
|
||
| const linksWithChat = useMemo(() => { | ||
| const chatLink = { name: "Chat", href: "/chat" }; | ||
| return isChatEnabled ? [...loggedInLinks, chatLink] : loggedInLinks; | ||
| }, [isChatEnabled]); | ||
|
|
||
| const shouldShowPreviewBanner = Boolean(isLoggedIn && previewBranchName); | ||
|
|
||
| return ( | ||
|
|
@@ -59,13 +53,19 @@ export function NavbarView({ isLoggedIn, previewBranchName }: NavbarViewProps) { | |
| {!isSmallScreen ? ( | ||
| <div className="flex flex-1 items-center gap-5"> | ||
| {isLoggedIn | ||
| ? linksWithChat.map((link) => ( | ||
| <NavbarLink | ||
| key={link.name} | ||
| name={link.name} | ||
| href={link.href} | ||
| /> | ||
| )) | ||
| ? loggedInLinks.map((link) => { | ||
| if (link.name === "Chat" && !isChatEnabled) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <NavbarLink | ||
| key={link.name} | ||
| name={link.name} | ||
| href={link.href} | ||
| /> | ||
| ); | ||
| }) | ||
| : loggedOutLinks.map((link) => ( | ||
| <NavbarLink | ||
| key={link.name} | ||
|
Comment on lines
+61
to
71
This comment was marked as outdated.
Sorry, something went wrong. |
||
|
|
@@ -114,22 +114,34 @@ export function NavbarView({ isLoggedIn, previewBranchName }: NavbarViewProps) { | |
| menuItemGroups={[ | ||
| { | ||
| groupName: "Navigation", | ||
| items: linksWithChat.map((link) => ({ | ||
| icon: | ||
| link.name === "Marketplace" | ||
| ? IconType.Marketplace | ||
| : link.name === "Library" | ||
| ? IconType.Library | ||
| : link.name === "Build" | ||
| ? IconType.Builder | ||
| : link.name === "Chat" | ||
| ? IconType.Chat | ||
| : link.name === "Monitor" | ||
| ? IconType.Library | ||
| : IconType.LayoutDashboard, | ||
| text: link.name, | ||
| href: link.href, | ||
| })), | ||
| items: loggedInLinks | ||
| .map((link) => { | ||
| if (link.name === "Chat" && !isChatEnabled) { | ||
| return null; | ||
| } | ||
|
|
||
| return { | ||
| icon: | ||
| link.name === "Marketplace" | ||
| ? IconType.Marketplace | ||
| : link.name === "Library" | ||
| ? IconType.Library | ||
| : link.name === "Build" | ||
| ? IconType.Builder | ||
| : link.name === "Chat" | ||
| ? IconType.Chat | ||
| : link.name === "Monitor" | ||
| ? IconType.Library | ||
| : IconType.LayoutDashboard, | ||
| text: link.name, | ||
| href: link.href, | ||
| }; | ||
| }) | ||
| .filter((item) => item !== null) as Array<{ | ||
| icon: IconType; | ||
| text: string; | ||
| href: string; | ||
| }>, | ||
| }, | ||
| ...dynamicMenuItems, | ||
| ]} | ||
|
Comment on lines
+137
to
147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The refactoring removes the dynamic creation of the "Chat" link. The new filtering logic on π Detailed AnalysisThe refactoring in π‘ Suggested FixReintroduce the logic to dynamically add the "Chat" link to the navigation links when π€ Prompt for AI AgentDid we get this right? π / π to inform future reviews. |
||
|
|
||
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.
Chat link never displays because it's not in source array
The
loggedInLinksarray inhelpers.tsxdoes not contain a "Chat" entryβit only includes Marketplace, Library, and Build. The old code dynamically added the Chat link to the array whenisChatEnabledwas true. The new code instead attempts to filter out a Chat link that doesn't exist in the source array. As a result, the Chat link will never be displayed regardless of whetherisChatEnabledis true or false.Additional Locations (1)
autogpt_platform/frontend/src/components/layout/Navbar/components/NavbarView.tsx#L116-L144