remove accountbutton
This commit is contained in:
parent
7927a62422
commit
b96068408e
6 changed files with 57 additions and 115 deletions
42
gui/src/components/AssistantAndOrgListbox/AccountOption.tsx
Normal file
42
gui/src/components/AssistantAndOrgListbox/AccountOption.tsx
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { isOnPremSession } from "core/control-plane/AuthTypes";
|
||||
import { useAuth } from "../../context/Auth";
|
||||
import { ListboxOption, useFontSize } from "../ui";
|
||||
|
||||
interface AccountOptionProps {
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export function AccountOption({ onClose }: AccountOptionProps) {
|
||||
const { session, logout, login } = useAuth();
|
||||
const tinyFont = useFontSize(-4);
|
||||
|
||||
// No account option for on-prem deployments
|
||||
if (session && isOnPremSession(session)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async function handleClick() {
|
||||
if (session) {
|
||||
logout();
|
||||
} else {
|
||||
await login(false);
|
||||
}
|
||||
onClose();
|
||||
}
|
||||
|
||||
return (
|
||||
<ListboxOption
|
||||
value={session ? "log-out" : "sign-in"}
|
||||
fontSizeModifier={-2}
|
||||
className="border-border border-b px-3 py-1.5"
|
||||
onClick={handleClick}
|
||||
>
|
||||
<div
|
||||
className="text-description flex flex-row items-center"
|
||||
style={{ fontSize: tinyFont }}
|
||||
>
|
||||
{session ? "Log out" : "Sign in"}
|
||||
</div>
|
||||
</ListboxOption>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,12 +1,20 @@
|
|||
import { useAuth } from "../../context/Auth";
|
||||
import { ScopeSelect } from "./ScopeSelect";
|
||||
|
||||
export function OrganizationInfo() {
|
||||
const { session } = useAuth();
|
||||
|
||||
return (
|
||||
<div className="border-border border-b px-2 py-3">
|
||||
<div className="flex flex-col gap-1">
|
||||
<label className="text-vsc-foreground ml-2 pb-0.5 font-semibold">
|
||||
Organization
|
||||
</label>
|
||||
<div className="ml-2 flex items-center gap-2 pb-0.5">
|
||||
<label className="text-vsc-foreground font-semibold">
|
||||
Organization
|
||||
</label>
|
||||
{!session && (
|
||||
<span className="text-description-muted">(Signed out)</span>
|
||||
)}
|
||||
</div>
|
||||
<ScopeSelect />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import {
|
|||
Transition,
|
||||
useFontSize,
|
||||
} from "../ui";
|
||||
import { AccountOption } from "./AccountOption";
|
||||
import { AssistantOptions } from "./AssistantOptions";
|
||||
import { OrganizationInfo } from "./OrganizationInfo";
|
||||
import { SelectedAssistantButton } from "./SelectedAssistantButton";
|
||||
|
|
@ -26,7 +27,7 @@ export function AssistantAndOrgListbox() {
|
|||
const currentOrg = useAppSelector(selectCurrentOrg);
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { isToolbarExpanded } = useLump();
|
||||
const { profiles, logout, selectedProfile, session, login } = useAuth();
|
||||
const { profiles, selectedProfile, session, login } = useAuth();
|
||||
const smallFont = useFontSize(-3);
|
||||
const tinyFont = useFontSize(-4);
|
||||
|
||||
|
|
@ -44,11 +45,6 @@ export function AssistantAndOrgListbox() {
|
|||
close();
|
||||
}
|
||||
|
||||
function onLogout() {
|
||||
logout();
|
||||
close();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let lastToggleTime = 0;
|
||||
const DEBOUNCE_MS = 800;
|
||||
|
|
@ -140,21 +136,7 @@ export function AssistantAndOrgListbox() {
|
|||
</div>
|
||||
</ListboxOption>
|
||||
|
||||
{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>
|
||||
)}
|
||||
<AccountOption onClose={close} />
|
||||
|
||||
<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"
|
||||
|
|
|
|||
|
|
@ -1,82 +0,0 @@
|
|||
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>
|
||||
);
|
||||
}
|
||||
|
|
@ -9,7 +9,6 @@ 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";
|
||||
|
|
@ -63,7 +62,6 @@ function ConfigPage() {
|
|||
showBorder
|
||||
onTitleClick={() => navigate("/")}
|
||||
title="Chat"
|
||||
rightContent={<AccountButton />}
|
||||
/>
|
||||
|
||||
{/* Tab Headers */}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ 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();
|
||||
|
|
@ -12,12 +11,7 @@ export default function HistoryPage() {
|
|||
className="flex flex-1 flex-col overflow-auto"
|
||||
style={{ fontSize: getFontSize() }}
|
||||
>
|
||||
<PageHeader
|
||||
showBorder
|
||||
onTitleClick={() => navigate("/")}
|
||||
title="Chat"
|
||||
rightContent={<AccountButton />}
|
||||
/>
|
||||
<PageHeader showBorder onTitleClick={() => navigate("/")} title="Chat" />
|
||||
<History />
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue