Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(frontend): Add admin button to user profile dropdown (#10774)

Nicholas Tindle6d39dfe3829b
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/NavbarView.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/NavbarView.tsx
index 1422f949ec..0b0c025b1b 100644
--- a/autogpt_platform/frontend/src/components/layout/Navbar/components/NavbarView.tsx
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/NavbarView.tsx
@@ -5,15 +5,17 @@ import { AccountMenu } from "./AccountMenu/AccountMenu";
import { LoginButton } from "./LoginButton";
import { MobileNavBar } from "./MobileNavbar/MobileNavBar";
import { NavbarLink } from "./NavbarLink";
-import { accountMenuItems, loggedInLinks, loggedOutLinks } from "../helpers";
+import { getAccountMenuItems, loggedInLinks, loggedOutLinks } from "../helpers";
import { useGetV2GetUserProfile } from "@/app/api/__generated__/endpoints/store/store";
import { AgentActivityDropdown } from "./AgentActivityDropdown/AgentActivityDropdown";
+import { useSupabase } from "@/lib/supabase/hooks/useSupabase";
interface NavbarViewProps {
isLoggedIn: boolean;
}
export const NavbarView = ({ isLoggedIn }: NavbarViewProps) => {
+ const { user } = useSupabase();
const { data: profile } = useGetV2GetUserProfile({
query: {
select: (res) => (res.status === 200 ? res.data : null),
@@ -21,6 +23,8 @@ export const NavbarView = ({ isLoggedIn }: NavbarViewProps) => {
},
});
+ const dynamicMenuItems = getAccountMenuItems(user?.role);
+
return (
<>
<nav className="sticky top-0 z-40 hidden h-16 items-center border border-white/50 bg-[#f3f4f6]/20 p-3 backdrop-blur-[26px] md:inline-flex">
@@ -50,7 +54,7 @@ export const NavbarView = ({ isLoggedIn }: NavbarViewProps) => {
userName={profile?.username}
userEmail={profile?.name}
avatarSrc={profile?.avatar_url ?? ""}
- menuItemGroups={accountMenuItems}
+ menuItemGroups={dynamicMenuItems}
/>
</div>
) : (
@@ -83,7 +87,7 @@ export const NavbarView = ({ isLoggedIn }: NavbarViewProps) => {
href: link.href,
})),
},
- ...accountMenuItems,
+ ...dynamicMenuItems,
]}
userEmail={profile?.name}
avatarSrc={profile?.avatar_url ?? ""}
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/helpers.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/helpers.tsx
index d2ef1bc241..46d63eafe8 100644
--- a/autogpt_platform/frontend/src/components/layout/Navbar/helpers.tsx
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/helpers.tsx
@@ -7,6 +7,7 @@ import {
IconMarketplace,
IconRefresh,
IconSettings,
+ IconSliders,
IconType,
IconUploadCloud,
} from "@/components/ui/icons";
@@ -90,6 +91,69 @@ export const accountMenuItems: MenuItemGroup[] = [
},
];
+export function getAccountMenuItems(userRole?: string): MenuItemGroup[] {
+ const baseMenuItems: MenuItemGroup[] = [
+ {
+ items: [
+ {
+ icon: IconType.Edit,
+ text: "Edit profile",
+ href: "/profile",
+ },
+ ],
+ },
+ {
+ items: [
+ {
+ icon: IconType.LayoutDashboard,
+ text: "Creator Dashboard",
+ href: "/profile/dashboard",
+ },
+ {
+ icon: IconType.UploadCloud,
+ text: "Publish an agent",
+ },
+ ],
+ },
+ ];
+
+ // Add admin menu item for admin users
+ if (userRole === "admin") {
+ baseMenuItems.push({
+ items: [
+ {
+ icon: IconType.Sliders,
+ text: "Admin",
+ href: "/admin/marketplace",
+ },
+ ],
+ });
+ }
+
+ // Add settings and logout
+ baseMenuItems.push(
+ {
+ items: [
+ {
+ icon: IconType.Settings,
+ text: "Settings",
+ href: "/profile/settings",
+ },
+ ],
+ },
+ {
+ items: [
+ {
+ icon: IconType.LogOut,
+ text: "Log out",
+ },
+ ],
+ },
+ );
+
+ return baseMenuItems;
+}
+
export function getAccountMenuOptionIcon(icon: IconType) {
const iconClass = "w-6 h-6";
switch (icon) {
@@ -109,6 +173,8 @@ export function getAccountMenuOptionIcon(icon: IconType) {
return <IconLibrary className={iconClass} />;
case IconType.Builder:
return <IconBuilder className={iconClass} />;
+ case IconType.Sliders:
+ return <IconSliders className={iconClass} />;
default:
return <IconRefresh className={iconClass} />;
}
diff --git a/autogpt_platform/frontend/src/components/ui/icons.tsx b/autogpt_platform/frontend/src/components/ui/icons.tsx
index 2f7262d98b..f1cba68689 100644
--- a/autogpt_platform/frontend/src/components/ui/icons.tsx
+++ b/autogpt_platform/frontend/src/components/ui/icons.tsx
@@ -1836,6 +1836,7 @@ export enum IconType {
Settings,
LogOut,
AutoGPTLogo,
+ Sliders,
}
export function getIconForSocial(