Compare commits

...

3 Commits

Author SHA1 Message Date
openhands
bde4a806be refactor: simplify exit project button
- Move endSession logic into ExitProjectButton component
- Remove onClick prop requirement
- Clean up unused code
2025-01-03 19:38:15 +00:00
openhands
43bce8f2d3 refactor: simplify homepage link to use native <a> tag
- Replace button with native <a> tag for better browser behavior
- Remove custom click handling and state management
- Clean up unused imports and code
2025-01-03 19:33:22 +00:00
openhands
a9254ed368 feat: improve homepage link behavior
- Remove confirmation modal when clicking homepage link
- Add cmd+click support to open in new tab
- Clean up state before navigation
2025-01-03 19:30:38 +00:00
4 changed files with 19 additions and 38 deletions

View File

@@ -1,5 +1,4 @@
import React from "react";
import { useLocation } from "react-router";
import FolderIcon from "#/icons/docs.svg?react";
import { useAuth } from "#/context/auth-context";
import { useGitHubUser } from "#/hooks/query/use-github-user";
@@ -11,7 +10,6 @@ import { ExitProjectButton } from "#/components/shared/buttons/exit-project-butt
import { SettingsButton } from "#/components/shared/buttons/settings-button";
import { LoadingSpinner } from "#/components/shared/loading-spinner";
import { AccountSettingsModal } from "#/components/shared/modals/account-settings/account-settings-modal";
import { ExitProjectConfirmationModal } from "#/components/shared/modals/exit-project-confirmation-modal";
import { SettingsModal } from "#/components/shared/modals/settings/settings-modal";
import { useSettingsUpToDate } from "#/context/settings-up-to-date-context";
import { useSettings } from "#/hooks/query/use-settings";
@@ -20,7 +18,6 @@ import { cn } from "#/utils/utils";
import { MULTI_CONVO_UI_IS_ENABLED } from "#/utils/constants";
export function Sidebar() {
const location = useLocation();
const user = useGitHubUser();
const { data: isAuthed } = useIsAuthed();
const { logout } = useAuth();
@@ -30,8 +27,7 @@ export function Sidebar() {
const [accountSettingsModalOpen, setAccountSettingsModalOpen] =
React.useState(false);
const [settingsModalIsOpen, setSettingsModalIsOpen] = React.useState(false);
const [startNewProjectModalIsOpen, setStartNewProjectModalIsOpen] =
React.useState(false);
const [conversationPanelIsOpen, setConversationPanelIsOpen] = React.useState(
MULTI_CONVO_UI_IS_ENABLED,
);
@@ -51,11 +47,6 @@ export function Sidebar() {
setAccountSettingsModalOpen(false);
};
const handleClickLogo = () => {
if (location.pathname.startsWith("/conversations/"))
setStartNewProjectModalIsOpen(true);
};
const showSettingsModal =
isAuthed && (!settingsAreUpToDate || settingsModalIsOpen);
@@ -64,7 +55,7 @@ export function Sidebar() {
<aside className="h-[40px] md:h-auto px-1 flex flex-row md:flex-col gap-1 relative">
<nav className="flex flex-row md:flex-col items-center gap-[18px]">
<div className="w-[34px] h-[34px] flex items-center justify-center">
<AllHandsLogoButton onClick={handleClickLogo} />
<AllHandsLogoButton />
</div>
{user.isLoading && <LoadingSpinner size="small" />}
{!user.isLoading && (
@@ -90,9 +81,7 @@ export function Sidebar() {
</button>
)}
<DocsButton />
<ExitProjectButton
onClick={() => setStartNewProjectModalIsOpen(true)}
/>
<ExitProjectButton />
</nav>
{conversationPanelIsOpen && (
@@ -116,11 +105,6 @@ export function Sidebar() {
onClose={() => setSettingsModalIsOpen(false)}
/>
))}
{startNewProjectModalIsOpen && (
<ExitProjectConfirmationModal
onClose={() => setStartNewProjectModalIsOpen(false)}
/>
)}
</>
);
}

View File

@@ -1,18 +1,16 @@
import { Tooltip } from "@nextui-org/react";
import AllHandsLogo from "#/assets/branding/all-hands-logo.svg?react";
import { TooltipButton } from "./tooltip-button";
interface AllHandsLogoButtonProps {
onClick: () => void;
}
export function AllHandsLogoButton({ onClick }: AllHandsLogoButtonProps) {
export function AllHandsLogoButton() {
return (
<TooltipButton
tooltip="All Hands AI"
ariaLabel="All Hands Logo"
onClick={onClick}
>
<AllHandsLogo width={34} height={23} />
</TooltipButton>
<Tooltip content="All Hands AI" closeDelay={100}>
<a
href="/"
aria-label="All Hands Logo"
className="w-8 h-8 rounded-full hover:opacity-80 flex items-center justify-center"
>
<AllHandsLogo width={34} height={23} />
</a>
</Tooltip>
);
}

View File

@@ -1,16 +1,15 @@
import NewProjectIcon from "#/icons/new-project.svg?react";
import { TooltipButton } from "./tooltip-button";
import { useEndSession } from "#/hooks/use-end-session";
interface ExitProjectButtonProps {
onClick: () => void;
}
export function ExitProjectButton() {
const endSession = useEndSession();
export function ExitProjectButton({ onClick }: ExitProjectButtonProps) {
return (
<TooltipButton
tooltip="Start new project"
ariaLabel="Start new project"
onClick={onClick}
onClick={endSession}
testId="new-project-button"
>
<NewProjectIcon width={28} height={28} />

View File

@@ -4,7 +4,7 @@ import { ReactNode } from "react";
interface TooltipButtonProps {
children: ReactNode;
tooltip: string;
onClick?: () => void;
onClick?: (e: React.MouseEvent) => void;
href?: string;
ariaLabel: string;
testId?: string;