Skip to content

Revert "remove accountbutton" #6614

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 0 additions & 51 deletions gui/src/components/AssistantAndOrgListbox/AccountOption.tsx

This file was deleted.

23 changes: 21 additions & 2 deletions gui/src/components/AssistantAndOrgListbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
Transition,
useFontSize,
} from "../ui";
import { AccountOption } from "./AccountOption";
import { AssistantOptions } from "./AssistantOptions";
import { ScopeSelect } from "./ScopeSelect";
import { SelectedAssistantButton } from "./SelectedAssistantButton";
Expand All @@ -34,6 +33,7 @@ export function AssistantAndOrgListbox() {
selectedProfile,
session,
login,
logout,
organizations,
refreshProfiles,
} = useAuth();
Expand All @@ -57,6 +57,11 @@ export function AssistantAndOrgListbox() {
close();
}

function onLogout() {
logout();
close();
}

useEffect(() => {
let lastToggleTime = 0;
const DEBOUNCE_MS = 800;
Expand Down Expand Up @@ -184,7 +189,21 @@ export function AssistantAndOrgListbox() {
</span>
</ListboxOption>

<AccountOption onClose={close} />
{session && (
<ListboxOption
value="log-out"
fontSizeModifier={-2}
className="border-border border-b px-3 py-1.5"
onClick={onLogout}
>
<div
className="text-description flex flex-row items-center"
style={{ fontSize: tinyFont }}
>
Log out
</div>
</ListboxOption>
)}

<div
className="text-description border-border flex items-center justify-between gap-1.5 border-x-0 border-b-0 border-t border-solid px-2 py-2"
Expand Down
82 changes: 82 additions & 0 deletions gui/src/pages/config/AccountButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { UserCircleIcon } from "@heroicons/react/24/solid";
import { isOnPremSession } from "core/control-plane/AuthTypes";
import { ScopeSelect } from "../../components/AssistantAndOrgListbox/ScopeSelect";
import {
Button,
Popover,
PopoverButton,
PopoverPanel,
Transition,
} from "../../components/ui";
import { useAuth } from "../../context/Auth";
import { useAppSelector } from "../../redux/hooks";
import { selectCurrentOrg } from "../../redux/slices/profilesSlice";

export function AccountButton() {
const { session, logout, login, organizations } = useAuth();
const selectedOrg = useAppSelector(selectCurrentOrg);

if (!session) {
return (
<Button
variant="outline"
className="mb-1 whitespace-nowrap py-1"
onClick={() => login(false)}
>
Sign in
</Button>
);
}

// No login button for on-prem deployments
if (isOnPremSession(session)) {
return null;
}

return (
<Popover className="relative">
{({ close }) => (
<>
<PopoverButton className="bg-vsc-background hover:bg-vsc-input-background text-vsc-foreground my-0.5 flex cursor-pointer rounded-md border-none px-2">
<div className="flex items-center gap-1.5">
<span className="font-medium">
{selectedOrg === null ? "Personal" : selectedOrg.name}
</span>
<UserCircleIcon className="h-6 w-6" />
</div>
</PopoverButton>

<Transition>
<PopoverPanel className="bg-vsc-input-background xs:p-4 absolute right-0 mt-1 rounded-md border border-zinc-700 p-2 shadow-lg">
<div className="flex flex-col gap-3">
<div className="flex flex-col">
<span className="font-medium">{session.account.label}</span>
<span className="text-lightgray text-sm">
{session.account.id}
</span>
</div>

{organizations.length > 0 && (
<div className="flex flex-col gap-1">
<label className="text-vsc-foreground text-xs">
Organization
</label>
<ScopeSelect onSelect={close} />
</div>
)}

<Button
variant="ghost"
onClick={logout}
className="!mx-0 w-full"
>
Sign out
</Button>
</div>
</PopoverPanel>
</Transition>
</>
)}
</Popover>
);
}
2 changes: 2 additions & 0 deletions gui/src/pages/config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useNavigate } from "react-router-dom";
import { PageHeader } from "../../components/PageHeader";
import { useNavigationListener } from "../../hooks/useNavigationListener";
import { fontSize } from "../../util";
import { AccountButton } from "./AccountButton";
import { HelpCenterSection } from "./HelpCenterSection";
import { IndexingSettingsSection } from "./IndexingSettingsSection";
import KeyboardShortcuts from "./KeyboardShortcuts";
Expand Down Expand Up @@ -62,6 +63,7 @@ function ConfigPage() {
showBorder
onTitleClick={() => navigate("/")}
title="Chat"
rightContent={<AccountButton />}
/>

{/* Tab Headers */}
Expand Down
8 changes: 7 additions & 1 deletion gui/src/pages/history/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useNavigate } from "react-router-dom";
import { History } from "../../components/History";
import { PageHeader } from "../../components/PageHeader";
import { getFontSize } from "../../util";
import { AccountButton } from "../config/AccountButton";

export default function HistoryPage() {
const navigate = useNavigate();
Expand All @@ -11,7 +12,12 @@ export default function HistoryPage() {
className="flex flex-1 flex-col overflow-auto"
style={{ fontSize: getFontSize() }}
>
<PageHeader showBorder onTitleClick={() => navigate("/")} title="Chat" />
<PageHeader
showBorder
onTitleClick={() => navigate("/")}
title="Chat"
rightContent={<AccountButton />}
/>
<History />
</div>
);
Expand Down
Loading