mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-04 21:23:07 +00:00
feat: refactor bug report button into a reusable component for improved sidebar functionality
This commit is contained in:
@@ -195,6 +195,32 @@ const PROJECT_THEME_OPTIONS = [
|
|||||||
})),
|
})),
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
// Reusable Bug Report Button Component
|
||||||
|
const BugReportButton = ({
|
||||||
|
sidebarExpanded,
|
||||||
|
onClick
|
||||||
|
}: {
|
||||||
|
sidebarExpanded: boolean;
|
||||||
|
onClick: () => void;
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
onClick={onClick}
|
||||||
|
className={cn(
|
||||||
|
"titlebar-no-drag p-1.5 rounded-lg",
|
||||||
|
"text-muted-foreground hover:text-foreground hover:bg-accent/80",
|
||||||
|
"transition-all duration-200 ease-out",
|
||||||
|
"hover:scale-105 active:scale-95",
|
||||||
|
sidebarExpanded && "absolute right-3"
|
||||||
|
)}
|
||||||
|
title="Report Bug / Feature Request"
|
||||||
|
data-testid={sidebarExpanded ? "bug-report-link" : "bug-report-link-collapsed"}
|
||||||
|
>
|
||||||
|
<Bug className="w-4 h-4" />
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export function Sidebar() {
|
export function Sidebar() {
|
||||||
const {
|
const {
|
||||||
projects,
|
projects,
|
||||||
@@ -836,6 +862,12 @@ export function Sidebar() {
|
|||||||
[trashedProjects, currentProject, globalTheme, upsertAndSetCurrentProject]
|
[trashedProjects, currentProject, globalTheme, upsertAndSetCurrentProject]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Handle bug report button click
|
||||||
|
const handleBugReportClick = useCallback(() => {
|
||||||
|
const api = getElectronAPI();
|
||||||
|
api.openExternalLink("https://github.com/AutoMaker-Org/automaker/issues");
|
||||||
|
}, []);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the system folder selection dialog and initializes the selected project.
|
* Opens the system folder selection dialog and initializes the selected project.
|
||||||
* Used by both the 'O' keyboard shortcut and the folder icon button.
|
* Used by both the 'O' keyboard shortcut and the folder icon button.
|
||||||
@@ -1394,50 +1426,14 @@ export function Sidebar() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{/* Bug Report Button - Only visible in expanded sidebar */}
|
{/* Bug Report Button - Inside logo container when expanded */}
|
||||||
{sidebarOpen && (
|
{sidebarOpen && <BugReportButton sidebarExpanded onClick={handleBugReportClick} />}
|
||||||
<button
|
|
||||||
onClick={() => {
|
|
||||||
const api = getElectronAPI();
|
|
||||||
api.openExternalLink(
|
|
||||||
"https://github.com/AutoMaker-Org/automaker/issues"
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
className={cn(
|
|
||||||
"titlebar-no-drag p-1.5 rounded-lg absolute right-3",
|
|
||||||
"text-muted-foreground hover:text-foreground hover:bg-accent/80",
|
|
||||||
"transition-all duration-200 ease-out",
|
|
||||||
"hover:scale-105 active:scale-95"
|
|
||||||
)}
|
|
||||||
title="Report Bug / Feature Request"
|
|
||||||
data-testid="bug-report-link"
|
|
||||||
>
|
|
||||||
<Bug className="w-4 h-4" />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Bug Report Button - Collapsed sidebar version */}
|
{/* Bug Report Button - Collapsed sidebar version */}
|
||||||
{!sidebarOpen && (
|
{!sidebarOpen && (
|
||||||
<div className="flex items-center justify-center px-3 py-2.5">
|
<div className="px-3 mt-1.5 flex justify-center">
|
||||||
<button
|
<BugReportButton sidebarExpanded={false} onClick={handleBugReportClick} />
|
||||||
onClick={() => {
|
|
||||||
const api = getElectronAPI();
|
|
||||||
api.openExternalLink(
|
|
||||||
"https://github.com/AutoMaker-Org/automaker/issues"
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
className={cn(
|
|
||||||
"titlebar-no-drag p-1.5 rounded-lg",
|
|
||||||
"text-muted-foreground hover:text-foreground hover:bg-accent/80",
|
|
||||||
"transition-all duration-200 ease-out",
|
|
||||||
"hover:scale-105 active:scale-95"
|
|
||||||
)}
|
|
||||||
title="Report Bug / Feature Request"
|
|
||||||
data-testid="bug-report-link-collapsed"
|
|
||||||
>
|
|
||||||
<Bug className="w-4 h-4" />
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -1815,7 +1811,7 @@ export function Sidebar() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Nav Items - Scrollable */}
|
{/* Nav Items - Scrollable */}
|
||||||
<nav className="flex-1 overflow-y-auto px-3 mt-5 pb-2">
|
<nav className={cn("flex-1 overflow-y-auto px-3 pb-2", sidebarOpen ? "mt-5" : "mt-1.5")}>
|
||||||
{!currentProject && sidebarOpen ? (
|
{!currentProject && sidebarOpen ? (
|
||||||
// Placeholder when no project is selected (only in expanded state)
|
// Placeholder when no project is selected (only in expanded state)
|
||||||
<div className="flex items-center justify-center h-full px-4">
|
<div className="flex items-center justify-center h-full px-4">
|
||||||
@@ -1828,7 +1824,7 @@ export function Sidebar() {
|
|||||||
) : currentProject ? (
|
) : currentProject ? (
|
||||||
// Navigation sections when project is selected
|
// Navigation sections when project is selected
|
||||||
navSections.map((section, sectionIdx) => (
|
navSections.map((section, sectionIdx) => (
|
||||||
<div key={sectionIdx} className={sectionIdx > 0 ? "mt-6" : ""}>
|
<div key={sectionIdx} className={sectionIdx > 0 && sidebarOpen ? "mt-6" : ""}>
|
||||||
{/* Section Label */}
|
{/* Section Label */}
|
||||||
{section.label && sidebarOpen && (
|
{section.label && sidebarOpen && (
|
||||||
<div className="hidden lg:block px-3 mb-2">
|
<div className="hidden lg:block px-3 mb-2">
|
||||||
@@ -1838,7 +1834,7 @@ export function Sidebar() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{section.label && !sidebarOpen && (
|
{section.label && !sidebarOpen && (
|
||||||
<div className="h-px bg-border/30 mx-2 mb-3"></div>
|
<div className="h-px bg-border/30 mx-2 my-1.5"></div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Nav Items */}
|
{/* Nav Items */}
|
||||||
|
|||||||
Reference in New Issue
Block a user