From 0090e4c58392bdf14899ff2afddb967ec2cdd032 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 21 Mar 2025 20:45:37 -0700 Subject: [PATCH] consolidate org switcher ui --- gui/src/pages/config/AccountButton.tsx | 13 +- gui/src/pages/config/AccountManagement.tsx | 150 --------------------- gui/src/pages/config/index.tsx | 3 - 3 files changed, 11 insertions(+), 155 deletions(-) delete mode 100644 gui/src/pages/config/AccountManagement.tsx diff --git a/gui/src/pages/config/AccountButton.tsx b/gui/src/pages/config/AccountButton.tsx index 3fb8427d2..0eaf4e471 100644 --- a/gui/src/pages/config/AccountButton.tsx +++ b/gui/src/pages/config/AccountButton.tsx @@ -4,9 +4,10 @@ import { Fragment } from "react"; import { SecondaryButton } from "../../components"; import { useAuth } from "../../context/Auth"; +import { ScopeSelect } from "./ScopeSelect"; export function AccountButton() { - const { session, logout, login } = useAuth(); + const { session, logout, login, organizations } = useAuth(); if (!session) { return ( @@ -16,7 +17,7 @@ export function AccountButton() { return ( - + @@ -37,6 +38,14 @@ export function AccountButton() { {session.account.id} + {organizations.length > 0 && ( +
+ + +
+ )} Sign out diff --git a/gui/src/pages/config/AccountManagement.tsx b/gui/src/pages/config/AccountManagement.tsx deleted file mode 100644 index 029718ed8..000000000 --- a/gui/src/pages/config/AccountManagement.tsx +++ /dev/null @@ -1,150 +0,0 @@ -import { Listbox, Transition } from "@headlessui/react"; -import { - ArrowTopRightOnSquareIcon, - ChevronUpDownIcon, - PlusCircleIcon, -} from "@heroicons/react/24/outline"; -import { Fragment, useContext } from "react"; -import AssistantIcon from "../../components/modelSelection/platform/AssistantIcon"; -import { useAuth } from "../../context/Auth"; -import { IdeMessengerContext } from "../../context/IdeMessenger"; -import { selectProfileThunk } from "../../redux"; -import { useAppDispatch } from "../../redux/hooks"; -import { ScopeSelect } from "./ScopeSelect"; - -export function AccountManagement({ hubEnabled }: { hubEnabled: boolean }) { - const dispatch = useAppDispatch(); - const ideMessenger = useContext(IdeMessengerContext); - - const { session, login, profiles, selectedProfile, selectedOrganization } = - useAuth(); - - const changeProfileId = (id: string) => { - dispatch(selectProfileThunk(id)); - }; - - function handleOpenConfig() { - if (!selectedProfile) { - return; - } - ideMessenger.post("config/openProfile", { - profileId: selectedProfile.id, - }); - } - - return ( -
-
-

Configuration

- {hubEnabled ? ( - // Hub: show org selector - session && ( -
- {`Organization`} - -
- ) - ) : ( - // Continue for teams: show org text -
You are using Continue for Teams
- )} - - {profiles ? ( - <> -
-
- {`${hubEnabled ? "Assistant" : "Profile"}`} -
- - {({ open }) => ( -
- -
- {selectedProfile && ( - - )} - - {selectedProfile?.title ?? "No Assistant Selected"} - -
-
-
-
- - - - {profiles.map((option, idx) => ( - - - - {option.title} - - - ))} - {hubEnabled && ( - { - if (session) { - ideMessenger.post("controlPlane/openUrl", { - path: "new", - orgSlug: selectedOrganization?.slug, - }); - } else { - login(false); - } - }} - > - - - Create new Assistant - - - )} - - - - {selectedProfile && ( -
- - - {hubEnabled - ? "Open Assistant configuration" - : "View Workspace"} - -
- )} -
- )} -
-
- - ) : ( -
Loading...
- )} -
-
- ); -} diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx index e3a28c0b2..885e629b9 100644 --- a/gui/src/pages/config/index.tsx +++ b/gui/src/pages/config/index.tsx @@ -17,7 +17,6 @@ import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { updateConfig } from "../../redux/slices/configSlice"; import { getFontSize } from "../../util"; import { AccountButton } from "./AccountButton"; -import { AccountManagement } from "./AccountManagement"; function ConfigPage() { useNavigationListener(); @@ -121,8 +120,6 @@ function ConfigPage() { />
- - {!controlServerBetaEnabled || hubEnabled ? (